At first these handlers were all lowercase. These functions are still
availabe, although the mixed case usage is encouraged
In GTK, and other toolkits, an event causes a signal to
be triggered and these handlers are called in response to that
signal. These signals have various names known to the GTK
programmer. say. These functions attempt to shield the
gWidgets user from needing to learn these signals. For
gWidgetsRGtk, if these handlers prove insufficient then the
non-exported addhandler
function has an additional
signal
argument: (obj,signal,handler,
action,...)
for specifying a GTK signal. By avoiding this, we
can make the gWidgets API non-toolkit specific.
The signals are defined to match the event
described by the method name, e.g., "doubleclick."
The handlers all have signature (h,...)
where the first
argument is a list with components obj
containing the
widget the handler is added to and action
containing
the values passed along to the action
argument. This
can be used to pass in other widget's names, when they can not
be found from a function closure, say.
The handlers do not have lazy evaluation. The value of
action
is the one at the time of creation of the
widget. (See the example). In GTK, a means to cheat this is to pass in
a gWidget instance, as the underlying GTK objects are stored
as pointers, not copies, so that when queried, their current
state is used.
addHandlerChanged
: { This handler is called when a widget
is "changed." This is interpreted differently by the various
widgets. For gedit
change refers to a changed value,
not a keystroke change (when ENTER is pressed). For notebooks,
this is called when a page is changed.
}
addHandlerKeystroke
: { This handler is called when keys are
pressed in the text widgets.
}
addHandlerClicked
: {This handler is called when a widget,
such as a button or label, is clicked.
}
addHandlerDoubleclick
: {This handler is called when a
widget is doubleclicked, like in the tree widget. Not all
widgets receive a double click signal. Only when a single
mouse click is needed for selection is this implemented.}
addHandlerMouseMotion
: {This handler is called when a
the mouse moves over a widget. In some toolkits it is called
just once per visit to the widget, for others maybe multiple
times. This is like a mouseover for web pages. The drag motion
handler is similar, only it is called when a drag event is
dragged over a widget.}
addHandlerExpose
: { handler is called when a widget is
exposed. For instance when a page in a notebook is exposed.}
addHandlerUnrealize
: { handler is called when a widget
is being unrealized.}
addHandlerDestroy
: { handler is called when a widget
is being destroyed. For top level windows, this usually allows
one to intercept the window destroy event for purposes of saving
work etc.}
addHandlerIdle
: { handler is called every so often,
and can be used to update a widget's content. This method has
an extra argument
interval
specifying the interval in milliseconds with a
default of 1000 or 1 second. }
Although not handlers, the addPopupMenu
method adds a
popup menu to a mouse click. The popup menu is specified using
a list that is passed to gmenu
.
A refinement of this is the add3rdMousePopupmenu
method
which puts the popupmenu on the right mouse click.