Ran Eilam


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
       '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.

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.


All events have a name and a source. Each possible event name, can have additional methods for describing that specific event:


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.


TextBox. value will return the new textbox value.


MenuList, ListBox, Button with TYPE_MENU. selectedIndex will return the index of the selected item in the widget.


ColorPicker. color will return the RGB value of the color selected.