I want that text inserted to a Gtk entry is only numeric (0…9). A behavior similar to GtkSpinButton with properties Numeric set to true.
Reading documentation, I’ve found that the right signal to connect is insert-text of GtkEditable interface:
by connecting to this signal and then stopping the signal with g_signal_stop_emission() , it is possible to modify the inserted text, or prevent it from being inserted entirely.
if I do
_onInsertText (entry, a, b, c) {
print (entry.text);
print (a);
print (b);
print (c);
if (a =="a") {
entry.stop_emission("insert-text");
}
}
i get
Gjs-WARNING **: 16:12:19.334: JS ERROR: TypeError: entry.stop_emission is not a function
the same code written in Python3 works, so, is it stop_emission supported in GJS? what do I do wrong?
You probably want stop_emission_by_name("insert-text").
PyGObject has an override for that function, I assume for backward compatibility. It has been deprecated, with a warning telling you to use stop_emission_by_name(), so you should change your Python code as well.