The
gtk:editable interface is an interface which should be implemented by text editing widgets, such as the
gtk:entry and
gtk:spin-button widgets.
It contains functions for generically manipulating an editable widget, a large
number of action signals used for key bindings, and several signals that an
application can connect to to modify the behavior of an editable widget.
Examples
As an example of the latter usage, by connecting the following handler to the
"insert-text" signal, an application can convert all entry
into an editable widget into uppercase.
;; Handler for the "insert-text" signal
(setf handlerid
(g:signal-connect entry "insert-text"
(lambda (editable text length position)
(g:signal-handler-block editable handlerid)
(gtk:editable-insert-text editable
(string-upcase text)
(cffi:mem-ref position :intptr))
(g:signal-stop-emission editable "insert-text")
(g:signal-handler-unblock editable handlerid))))
Signal Details
The "changed" signal
lambda (editable) :run-last
- editable
- The gtk:editable widget which received the signal.
The signal is emitted at the end of a single user visible operation on
the contents of the editable widget. For example, a paste operation that
replaces the contents of the selection will cause only one signal
emission, even though it is implemented by first deleting the selection,
then inserting the new content, and may cause multiple
"notify::text" signals to be emitted.
The "delete-text" signal
lambda (editable start end) :run-last
- editable
- The gtk:editable widget which received the signal.
- start
- The integer with the start position.
- end
- The integer with the end position.
The signal is emitted when text is deleted from the editable widget by
the user. The default handler for this signal will normally be responsible
for deleting the text, so by connecting to this signal and then stopping the signal with the
g:signal-stop-emission function, it is possible
to modify the range of deleted text, or prevent it from being deleted entirely. The
start and
end parameters are interpreted as for the
gtk:editable-delete-text function.
The "insert-text" signal
lambda (editable text length position) :run-last
- editable
- The gtk:editable widget which received the signal.
- text
- The string with the new text to insert.
- length
- The integer with the length of the new text, in bytes, or -1 if text is null-terminated.
- position
- The pointer to an integer with the position, in
characters, at which to insert the new text. This is an in-out
parameter. After the signal emission is finished, it should point
after the newly inserted text. You get the Lisp value of position with the call (cffi:mem-ref position :intptr).
The signal is emitted when text is inserted into the editable widget by
the user. The default handler for this signal will normally be responsible
for inserting the text, so by connecting to this signal and then stopping the signal with the
g:signal-stop-emission function, it is possible
to modify the inserted text, or prevent it from being inserted entirely.