I’m contributing to a library in the nim programming language that wraps gtk and provides the widgets etc. in a more declarative fashion.
I am currently wrapping the EditableLabel widget and I’m noticing things that make me feel like I’m missing something. Particularly as I only have beginner knowledge of gtk as well as native GUI development generally.
For context, the library generally works by having a struct (well, in nim those are called “objects”, but there’s no methods attached by default) with basically the same properties as the gtk-widget. If the nim-program updates the state, it syncs those changes to the gtk-widget via the widget’s setters. If the gtk-widget gets updated via e.g. user interaction, it syncs those changes back to its own state by listening to signals accordingly.
With EditableLabel my approach causes me some problems:
When you edit an EditableLabel, that implicitly changes its edited state to
true, when you move focus away from it that changes its edited state to
false. From what I can see though, there is no signal for that, so I can’t sync those state changes back to my own struct. Is my understanding there so far correct? If so, are there any signals I’m not yet aware of that I could still listen to to catch those changes?
EditableLabel does not seem to have an
activatesignal (unlike e.g. SearchEntry) or an equivalent to a
stopSearchsignal (which SearchEntry has) . That means when you hit enter while an EditableLabel is in focus, no signal (that I’m aware of) fires, same for pressing Esc. The behaviour I wanted to implement originally, was that if you hit enter, I call
gtk_editable_label_stop_editingwith commit = true, if you hit Esc I call
gtk_editable_label_stop_editingwith commit = false and in both cases I set editing = false. Are there ways for me to even notice those keypresses when they’re from editing an EditableLabel?
Particularly issue 2 makes me think I’m misunderstanding the intended usecase for EditableLabel (?).
I thought it was kinda like a lot of the fields on a BitBucket webpage: It looks like uneditable text but is actually sort of “Hiding” a form. If you want to edit it, you can click into it, modify it, press enter and bam, updated the field and it looks as “uneditable” as before, no “visuals” of a form on the page. Thus I wanted to wrap it that way.
Is that perhaps the wrong idea and it should be used in a different manner?