[Gambas-user] TableView.Edit: Save event not triggered by ENTER key
Benoît Minisini
gambas at ...1...
Tue Mar 25 01:10:04 CET 2014
Le 19/03/2014 23:59, T Lee Davidson a écrit :
> In the Gambas3 Documentation at
> http://www.gambasdoc.org/help/comp/gb.form/tableview?v3 it says:
> "Hitting the ENTER or the RETURN key moves to the next cell like the
> right arrow key. But if the end of the TableView is reached, the Insert
> event is raised."
>
> I surmised that this will trigger the Save event. But the ENTER key (on
> the numeric keypad) does not trigger the Save event.
>
> Is this and error in the Docs, or a bug, or something else I may have
> missed?
>
> Thanks,
> Lee
>
The ENTER or RETURN key does raise the Save event, but the event is
raised only if needed (i.e. if the cell has been modified).
> P.S. On semi-related note, That page also says, "If the user modifies
> the cell contents, then the Save event is raised, and you must actually
> save the data during the Save event handler. This is not automatic!"
>
> Not realizing exactly what, "save the data," meant, I called
> TableView.Save from within the Save event to save the data. I got a
> Stack Overflow error. Duh.
>
> The data just needs to be written to the TableView cell as in
> "TableView1[Row, Column].Text = Value".
>
The Save event means that you have to save the new data somewhere,
because the TableView won't do it for you. The new data to save is the
third argument of the Save event handler.
Then it's up to you to decide if you store the actual TableView contents
inside the TableView (i.e. by setting the Text property of the cell
explicitely), or if you provide the contents through the Data event.
The Save() method is called to trigger all that process (it means "do
raise the Save event"). It actually saves nothing. So don't call it from
the Save event handler!
Regards,
--
Benoît Minisini
More information about the User
mailing list