O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

The first Button has the input focus

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required