To connect handler to a signal, connect-signal
function is used. Function disconnect-signal
removes the connected signal.
(connect-signal object signal handler &key after) => handler-id
disconnect-signal
Connects the handler
to signal signal
on object object
. Signature of handler
should comply with signature of a signal. handler
will be called with arguments of type specified by signal with the object (on which the signal was emitted) prepended to them and it should return the value of the signal's return type.
(disconnect-signal object handler-id)
Disconnects the signal handler identified by handler-id from the corresponding signal for object. handler-id is the integer identifying the signal handler; connect-signal
returns handler identifiers.
Example:
(defvar *d* (make-instance 'gtk:dialog)) => *D* *d* => #<GTK:DIALOG {1002D866F1}> (parse-signal-name "GtkDialog" "response") => #<Signal [#86] void GtkDialog.response(gint) [RUN-LAST]> (connect-signal *d* "response" (lambda (dialog response-value) (print dialog) (print response-value))) (emit-signal *d* "response" 14) => ;; Prints: #<GTK:DIALOG {1002D866F1}> 14
Function emit-signal
is used to emit signals on objects.
(emit-signal object signal-name &rest args) => return-value
Emits the signal and calls all handlers of the signal. If signal returns a value, it is returned from emit-signal
.
Example:
(defvar *d* (make-instance 'gtk:dialog)) => *D* *d* => #<GTK:DIALOG {1002D866F1}> (parse-signal-name "GtkDialog" "response") => #<Signal [#86] void GtkDialog.response(gint) [RUN-LAST]> (connect-signal *d* "response" (lambda (dialog response-value) (print dialog) (print response-value))) (emit-signal *d* "response" 14) => ;; Prints: #<GTK:DIALOG {1002D866F1}> 14