Book HomeMastering Perl/TkSearch this book

7.14. Active Versus Selected

The activate method sets the Listbox item at index to the active element. This allows you to access this item later using the "active" index. Figure 7-5 shows two windows with active elements underlined. Each Listbox also has the black highlight rectangle around it that 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-5

Figure 7-5. Windows showing a Listbox with an "active" element



Library Navigation Links

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