Scrolling Methods

The Listbox can be scrolled both horizontally and vertically so it has both xview and yview methods and all their associated forms. These forms and how to use them are described in detail in Chapter 6.

The scan method allows you to use a really fast scrolling method. It is automatically bound to the second mouse button by the Listbox. Here is how you can do the same thing within your window:

$mw->bind("Listbox", "<2>",['scan','mark',Ev('x'),Ev('y')]);
$mw->bind("Listbox", "<B2-Motion>",['scan','dragto',Ev('x'),Ev('y')]);

When you click in the window with the second mouse button and then move your mouse around, you’ll see the contents of the Listbox zip by at super-fast speed. You could change the second argument of each bind statement if you wanted to bind this to another combination of keys/mouse actions. The bind method is explained in Chapter 15.

Get Mastering Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.