Connect to when GtkTextView changes its contents

I’m trying to do the equivalent of connect_changed from GtkEntry, but for GtkTextView. Looking at the signals, only connect_preedit_changed seems to be related, but it doesn’t get emitted when I type inside a GtkTextView.

Code that works for GtkEntry, for reference:

        self.connect_changed(move |entry| {
            let content = entry.buffer().text().to_string();

            // ...
        });

What’s the proper way of running code when the user is typing in a GtkTextView?

Hi,

You should track changes on the GtkTextBuffer side : Gtk.TextBuffer.changed

GtkTextView is just displaying the GtkTextBuffer and managing text input, can’t use it to track the internals.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.