O'Reilly logo

Learning Perl/Tk by Nancy Walsh

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

7.14. Active Versus Selected

The activate method will set the listbox item at index index to the active element. This allows you to access this item later using the "active" index. Figure 7.4 shows two windows with active elements underlined. Each listbox also has the black highlight rectangle around it, which indicates it has the keyboard focus (the active element isn't seen as marked unless the listbox has focus).

# The first window activates the item "four"
$lb->activate(3);
$lb->focus();
# The second window activates the item "three"
$lb2->activate(2);
$lb2->focus();
Figure 7.4. Windows showing a listbox with an "active" element

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