Hi,
I have a TreeView connected to a model (a ListStore).
The TreeView shows the data that is stored in the ListStore and the
ListStore gets updated when the user enters data into a cell, so you
could say it works fine.
Except in the following case: once the user is done editing, he presses a button in order to go to the next step. If the user is currently editing a cell, the changes in that cell will be lost. If the user presses enter or clicks on another cell after editing, the changes will be saved. But it isn't natural to do so, he will just press "Next" and expect the data to be there.
So my problem is: how do you save changes from a editable cell when a button (unrelated to the cell) is pressed?
So far, my approach to solving this problem has been to attach handlers to several signals in an attempt to "rescue" the data before it is erased. I have created handlers for the following signals:For the TreeView:
TreeView focus-out
TreeView cursor-changed
TreeView columns-changed
For the CellRenderer of the editable column:
CellRenderer editing-started
CellRenderer editing-canceled
For the CellEditable object I get when CellRenderer.editing-started is triggered
CellEditable editing-done
For the "Next" Button
Button pressed
Button clicked
When I edit a cell and then press "Next", the following sequence of events is triggered:
1. CellRenderer editing-started
2. TreeView cursor-changed
3. TreeView focus-out
... now I type in the cell, and press "Next"...
4. CellRenderer editing-canceled
5. CellEditable editing-done
6. Button pressed
7. Button clicked
I've been trying to find an event that is triggered before editing-canceled, so that I can call CellRenderer::stop_editing(bool canceled = false) hoping that this will prevent the data from being erased. But I don't know if such event exists and don't even know if calling stop_editing will work. Do you know of an event I could use to attempt a solution?
Can you think of other approaches to this problem? There must be a relatively easy solution to this seemingly simple problem out there, I've been struggling with it several hours already...
Thanks in advance.