Hi, I am trying to make a script where it is possible to use the enter key same as pressing a command button, but only if the entry widget has focus. So that is what i am trying to determine. Here is my code, i just put this together because i am writing a larger program.
use strict; use warnings; use Tk; my $mw = new MainWindow; my $text = $mw->Scrolled("Text", -scrollbars => 'e')->pack(-side=>'bot +tom',-anchor=>'w'); my $label = $mw->Label(-text=>"hello")->pack(-side=>'left',-anchor=>'n +'); my $entry = $mw->Entry()->pack(-side=>'left',-anchor=>'n'); $mw->bind('<Key-Return>',\&verwijs); $entry->focus; MainLoop; sub verwijs{ my $who = $mw->focusCurrent; print %$who; }
The output = "_TkValue_.entry_XEvent_XEvent=SCALAR(0x1ffc334)". So this means the entry widget had focus, but how do i write this an test for it? I can't find any documentation. Thank you.
In reply to [Tk] use enter key iso command button by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |