The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

XUL::Node::Event - a user interface event

SYNOPSYS

  # 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
  });

DESCRIPTION

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.

EVENT TYPES

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

Click

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.

Change

TextBox. value will return the new textbox value.

Select

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

Pick

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