I am stuck by a technical problem and hope to acquire your intelligent help.
I stumble across a hassle during a course of implementing a GUI app named after “setup wizard” where clicking the previous / next button is expected to dynamically changes the displaying content. I was stuck, because the click event handle of the previous / next button is merely able to remove the old content, but doesn’t add the new one. Consequently, after the next button is clicked, the displaying region becomes empty.
In my program, a single closure (named after “render”) is written to stuff widget to the displaying region which is a GtkFrame widget. It’s weird that the same closure is capable of adding the child widget (e.g. gtk::Box) to GtkFrame and showing it during the GUI initialization (i.e. inside “application.connect_activate(…)”), but takes no effect in the event-handle closure for receiving the clicking signal. I don’t make certain what I lost.
My widget is as follow
GtkApplicationWindow
- GtkPanel : Vertical direction
- GtkScrolledWindow
- GtkViewport
- GtkAlignment : align to center
- Gtk Frame : **I’d like to dynamically change its only one child widget, when the next / previous button is clicked.
- GtkAlignment : align to center
- GtkViewport
- GtkScrolledWindow
- GtkButtonBox : Vertical direction**
- GtkButton : Preview
- GtkButton : Next
- GtkButton : Submit
My source code is here. After (cargo run), the JSON file under the (assets) folder is loaded which has a (prompts) node in the top level. The first entry of the (prompts) object will be rendered against the 1st scene during the GUI initialization where only a GtkLabel is drawn with the (message) property value from JSON.
At the moment, clicking the next button erases the GtkLabel widget, because of the GtkFrame::remove(). And then, clicking the preview button takes no effect for redrawing the GtkLabel widget again, even though the GtkFrame::add() is run without any panic!. If you open the source code by using VSCode including the LLDB plugin, typing the F5 key on the keyboard will launch the debugging mode. And then, it’s observed that the GtkFrame::add() is run with the breakpoint on it.
The below #4 step takes no effect for the button-clicking occasion.
I’d like to resolve the problem, but am not aware of what is erroneous. I really need your technical assistance.