Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

c - GtkEntry text change signal

How can I connect a signal callback for any kind of change in a GtkEntry's buffer, including character added, deleted, text pasted or cut? I've looked in the docs for GtkWidget, GtkEntry and GtkEntryBuffer without finding this.

Note: if my question was badly worded, think of the HTML DOM's change event, except that it's fired greedily after every single keypress or event that causes a change, and not only checked on unfocus.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is the changed signal (of the GtkEditable interface):

The ::changed signal is emitted at the end of a single user-visible operation on the contents of the GtkEditable.

E.g., 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).

(I found that by checking the implemented interfaces section.)

This indicates that you can also connect to the notify signal of the text property (specifically, notify::text).

There is also the preedit-changed signal:

If an input method is used, the typed text will not immediately be committed to the buffer. So if you are interested in the text, connect to this signal.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...