home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeMastering Perl/TkSearch this book

13.21. Waiting for Events to Happen

At certain points in your application, it makes sense to wait until something happens. For instance, if you create a ColorEditor window and want it to assign the color the user selects to a variable, you can use waitVariable to wait until the variable is set. For complete details, see Chapter 15, "Anatomy of the MainLoop".

To have a program wait until a variable's value is changed, call waitVariable:

$widget->waitVariable(\$var);

Processing will continue as soon as the value contained within $var is changed to something different. To wait until a $widget is visible, use waitVisibility:

$widget->waitVisibility;

To wait until a widget is destroyed, call waitWindow:

$widget->waitWindow;

When you call these methods, nothing will happen in your program until the requested event has taken place.

An alternative to waitWindow is OnDestroy, where you specify a callback. The widget methods are still available when you use OnDestroy:

$widget->OnDestroy(sub { ... });


Library Navigation Links

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