| 1 | # NOTE: Derived from blib/lib/Tk/Toplevel.pm. |
| 2 | # Changes made here will be lost when autosplit is run again. |
| 3 | # See AutoSplit.pm. |
| 4 | package Tk::Toplevel; |
| 5 | |
| 6 | #line 80 "blib/lib/Tk/Toplevel.pm (autosplit into blib/lib/auto/Tk/Toplevel/FG_Create.al)" |
| 7 | #---------------------------------------------------------------------- |
| 8 | # |
| 9 | # Focus Group |
| 10 | # |
| 11 | # Focus groups are used to handle the user's focusing actions inside a |
| 12 | # toplevel. |
| 13 | # |
| 14 | # One example of using focus groups is: when the user focuses on an |
| 15 | # entry, the text in the entry is highlighted and the cursor is put to |
| 16 | # the end of the text. When the user changes focus to another widget, |
| 17 | # the text in the previously focused entry is validated. |
| 18 | # |
| 19 | |
| 20 | #---------------------------------------------------------------------- |
| 21 | # tkFocusGroup_Create -- |
| 22 | # |
| 23 | # Create a focus group. All the widgets in a focus group must be |
| 24 | # within the same focus toplevel. Each toplevel can have only |
| 25 | # one focus group, which is identified by the name of the |
| 26 | # toplevel widget. |
| 27 | # |
| 28 | sub FG_Create { |
| 29 | my $t = shift; |
| 30 | unless (exists $t->{'_fg'}) { |
| 31 | $t->{'_fg'} = 1; |
| 32 | $t->bind('<FocusIn>', sub { |
| 33 | my $w = shift; |
| 34 | my $Ev = $w->XEvent; |
| 35 | $t->FG_In($w, $Ev->d); |
| 36 | } |
| 37 | ); |
| 38 | $t->bind('<FocusOut>', sub { |
| 39 | my $w = shift; |
| 40 | my $Ev = $w->XEvent; |
| 41 | $t->FG_Out($w, $Ev->d); |
| 42 | } |
| 43 | ); |
| 44 | $t->bind('<Destroy>', sub { |
| 45 | my $w = shift; |
| 46 | my $Ev = $w->XEvent; |
| 47 | $t->FG_Destroy($w); |
| 48 | } |
| 49 | ); |
| 50 | # <Destroy> is not sufficient to break loops if never mapped. |
| 51 | $t->OnDestroy([$t,'FG_Destroy']); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | # end of Tk::Toplevel::FG_Create |
| 56 | 1; |