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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Tk notebook entry focus trouble ...help !

Status
Not open for further replies.

NEVERSLEEP

Programmer
Apr 14, 2002
667
CA
Greetings all,
Im having a trouble with a perl/Tk app of mine
im trying to ...well let me explain first
$nb is a Notebook widget
$entry is a Entry widget ($p1->Entry ...)
so im trying to set the focus on $entry each time
$p1 is raised i thought it would have been easy ...
but i didn't found a ->FOCUS method ...
so below is what i tried it works but .. only if there
is some value in this $entry so before i go defined or not ...
is there just a SETFOCUS method ?
thanks

my $p1 = $nb->add(
'Page1',
-label => 'Page One',
-raisecmd => sub {$entry->icursor(length $entry->get);}
); ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
There is a -takefocus option that is a standard widget option. I don't know if it will help you but it is documented in the Tk::eek:ptions manpage.
 
-takefocus (i think) call a callback when the focus is on
the widget

the thing im trying to do here is SET THE FOCUS on that entry

kidda like $entry->PLACE_THE_CURSOR ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
hummm -takefocus i not it ! green text is from aspn

sometimes it dosen't hurts to try the ovious [lol]
$entry->focus;
it worked ! (but i didn't found docs on this ...)

Name: takeFocus
Class: TakeFocus
Switch: -takefocus

Determines whether the window accepts the focus during keyboard traversal (e.g., Tab and Shift-Tab). Before setting the focus to a window, the traversal scripts consult the value of the takeFocus option. A value of 0 means that the window should be skipped entirely during keyboard traversal. 1 means that the window should receive the input focus as long as it is viewable (it and all of its ancestors are mapped). An empty value for the option means that the traversal scripts make the decision about whether or not to focus on the window: the current algorithm is to skip the window if it is disabled, if it has no key bindings, or if it is not viewable. If the value has any other form, then the traversal scripts take the value, append the name of the window to it (with a separator space), and evaluate the resulting string as a Callback. The script must return 0, 1, or an empty string: a 0 or 1 value specifies whether the window will receive the input focus, and an empty string results in the default decision described above. Note: this interpretation of the option is defined entirely by the Callbacks that implement traversal: the widget implementations ignore the option entirely, so you can change its meaning if you redefine the keyboard traversal scripts.
---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top