Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set focus troubles 1

Status
Not open for further replies.

reggler

Programmer
Nov 13, 2008
63
0
0
CA
Hi,
I would like to set the focus onto an entry field upon a certain window appears and i tried this:
after idle [list focus -force .operatorWindow.opEntry]
now, this does not work.... but
GUI::Info_DialogWIN "focus!"
after idle [list focus -force .operatorWindow.opEntry]
works just fine, the Info_DialogWIN proc just displays an information message that takes the focus away from . I ssume....so how can i get the focus on .operatorWindow.opEntry?
I've tried setting it on .operatorWindow first but that doesn't seem to work either...

Help would be appreciated!

Thanks

Ron
Hours of planing can save weeks of coding
 
Not sure what you're trying to accomplish with [list ...]. I assume that your idle in after idle is a reference to the instance of the window (upon a certain window appears). According to the man page:
after idle script ?script script ...?
you should be able to just:
Code:
after idle focus -force .operatorWindow.opEntry

_________________
Bob Rashkin
 
well that list thing was actually just a test i had tried just "after idle focus -force .operatorWindow.opEntry" earlier but again - only works with the message box that takes the focus off my main window.... :(

Ron
Hours of planing can save weeks of coding
 
sleeping 10ms seems to do the job to give the Windows message queue some time to work and then set the focus on the entry widget:
Code:
    finaltest::delay 10
    after idle focus -force .operatorWindow.opEntry
works fine.

Ron
Hours of planing can save weeks of coding
 
I suspect, then, that idle isn't triggered by the loading of the window.

_________________
Bob Rashkin
 
Yup seems like, my book says
"after idle command- Runs command at the next idle moment."
Can i do anything to get it triggered correctly?

Ron
Hours of planing can save weeks of coding
 
You could have a variable whose value changes right after the window is built, then use vwait.

_________________
Bob Rashkin
 
that doesn't really seem any better than sleeping for 10ms - even it would optimize the wait time of course but that's in this case no issue anyways - as long as the delay can be kept short... and an explicit sleep seems to be easier to read too I believe...

Ron
Hours of planing can save weeks of coding
 
I would only suggest that "vwait" allows the focus to be event-driven rather than a time that could vary depending on platform.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top