XUL::Node::Event - a user interface event
use XUL::Node; # listening to existing widget add_listener $button => Click => sub { print 'clicked!' }; # listening to widget in constructor, listener prints event value TextBox(Change => sub { print shift->value }); # more complex listeners add_listener $check_box => (Click => sub { my $event = shift; # event is the only argument print 'source: ' . $event->source, # source widget, a XUL::Node ', name: ' . $event->name, # Click ', checked: '. $event->checked; # Perl boolean });
Events are objects recieved as the only argument to a widget listener callback. You can interrogate them for information concerning the event.
Each type of widget has one or more event types that it fires. Buttons fire Click, for example, but list boxes fire Select.
Click
Select
Events from the UI can have side effects: a change in the textbox on the screen, requires that the value attribute of the Perl textbox object change as well, to stay in sync. This happens automatically, and before listener code is run.
value
All events have a name and a source. Each possible event name, can have additional methods for describing that specific event:
name
source
Button, ToolBarButton, MenuItem when inside a Menu, CheckBox, Radio. Checkbox and radio events provide a method checked, that returns the widget state as a boolean.
Button, ToolBarButton, MenuItem when inside a Menu, CheckBox, Radio
checked
TextBox. value will return the new textbox value.
TextBox
MenuList, ListBox, Button with TYPE_MENU. selectedIndex will return the index of the selected item in the widget.
MenuList, ListBox, Button with TYPE_MENU
selectedIndex
ColorPicker. color will return the RGB value of the color selected.
ColorPicker
color
Aspect::Library::Listenable
To install XUL::Node, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XUL::Node
CPAN shell
perl -MCPAN -e shell install XUL::Node
For more information on module installation, please visit the detailed CPAN module installation guide.