Ran Eilam > XUL-Node-0.06 > XUL::Node::Event

Download:
XUL-Node-0.06.tar.gz

Annotate this POD

CPAN RT

New  5
Open  1
View/Report Bugs
Source  

NAME ^

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

SYNOPSYS ^

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

DESCRIPTION ^

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.

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

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.

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.

SEE ALSO ^

Aspect::Library::Listenable

syntax highlighting: