start page | rating of books | rating of authors | reviews | copyrights

Book HomeMastering Perl/TkSearch this book

4.18. Focus Options

In an application, you can tab between widgets to make them available for input from the keyboard. The application indicates that a widget is available for keyboard input by drawing an outline around it in black (this is called the highlight rectangle; see Figure 4-37). If a widget has this outline around it, it is said to have the focus of the application. (You can force the focus of an application to start with a specific widget by using $widget->focus;.) Once a Button has the focus, you can use the spacebar on your keyboard to activate it instead of using the mouse.

Figure 4-37

Figure 4-37. The first Button has the input focus

You can force the application not to allow your Button to receive the keyboard focus at all by using the -takefocus option:

-takefocus => 0 | 1 | undef

The -takefocus option is normally set to an empty string (undef), which allows the application to dynamically decide if the widget will accept focus. If a widget has its state set to 'disabled', it will be skipped over when users tab through all the widgets. To have the application always ignore the widget when tabbing through, use -takefocus => 0. To have the application always allow focus to the widget, use -takefocus => 1.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.