These functions allow one to register an R expression,
call or more typically a function as a
callback for a Gtk event, and also control
the activity status of that callback.
gtkObjectAddCallback
registers the S expression, call or function
as a callback or event handler
for the specific event type
with the widget of interest.
When the event occurs for this widget,
the S "expression" will be invoked.
The block and unblock functions allow one to temporarily suspend and re-enable a callback. When suspended, any calls to the function that would normally occur are not invoked.
gtkObjectRemoveCallback
allows one to unregister a callback using
the identifier obtained when call gtkObjectAddCallback
.
gtkObjectDisconnectCallback
un-registers a callback.
gtkObjectAddCallback(w, signal, f, data = NULL, object = TRUE, after = TRUE)
gtkAddCallback(w, signal, f, data = NULL, object = TRUE, after = TRUE)
gtkObjectBlockCallback(obj, id)
gtkObjectUnblockCallback(obj, id)
gtkObjectDisconnectCallback(obj, id)
f
.f
when the callback
is invoked. This can be use to parameterize a callback function so that it
behaves differently. This is passed as the first argument
to the function if object
is TRUE
or as the final argument if object
is FALSE
.
If f
is an expression or a call, data
can be
an environment. In this case, f
is evaluated within
this environment. This allows the code registering the callback
to control the scope of the evaluation.
data
argument
to be the first argument to the callback function and the
Gtk object for which the event occurs to be the last argument,
or vice-versa. This is sometimes convenient and is the difference
between a call to gtk_signal_connect
and
gtk_signal_connect_object
at the Gtk interface level.
This argument is only meaningful if data
is not missing
as no data argument is passed to the callback if it is not supplied.
void
,
this rarely matters and one can accept the default.
gtkObjectAddCallback
returns an object of class
CallbackID
that provides a unique identifier
for the Gtk-level handler.
This is an integer value whose name attribute gives the name of the signal.
This object can be used to suspend (block), remove (disconnect)
and reactivate (unblock) a callback.The other functions return a logical value indicating if they were
succesful or else result in an error.
gtkButton
if (gtkInit()) {
w <- gtkWindow(show = FALSE)
b <- gtkButton("Hit me")
w$add(b)
w$show()
gtkAddCallback(b, "clicked", function(w) {
help.start();
TRUE
})
}
Run the code above in your browser using DataLab