XUL::Node::Event - a user interface event
# listening to existing widget $button->attach(Change => sub { print 'clicked!' }); # listening to widget in constructor, listener prints event value TextBox(Change => sub { print shift->value }); # more complex listeners $check_box->attach(Click => sub { my $event = shift; # XUL::Node::Event object is only argument print 'source: ' . $event->source, # source widget, a XUL::Node object ', name: ' . $event->name, # Click ', checked: '. $event->checked; # Perl boolean });
Events are objects recieved as the only argument to a widget listener callback. You can interogate 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
CheckBox, Button, Radio, ToolBarButton, MenuItem when inside a Menu. Checkbox and radio events provide a method checked, that returns the widget state as a boolean.
CheckBox, Button, Radio, ToolBarButton, MenuItem when inside a Menu
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
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.