I am developing an app based around a tab panel. I want to remind the user to save their changes on the tab they are using BEFORE they move on to the next tab.
I am doing the checking in the Tab Change event and that is all working fine.
However, it looks a bit odd because the display is showing the new tab when the message box pops up to say ‘please save your changes’ from the previous tab.
I realise I could just auto-save the data as they move around but I wanted it to be a more explicit decision to save.
So is there any way to trap the change of a tab panel AFTER the tab button for the new tab is pressed but BEFORE the tab panel actually changes. That way the ‘please save your data’ message will appear on the tab that the saving refers to.
I have read the docs and dont see any way to do this with the standard Xojo tab panel.
Hope that makes sense
Use custom tab panels like mine (https://www.mothsoftware.com/content/xojo/xojo.php) and trap the mouse down. I need to upload a newer version of my code.
Thank you for that, I will give it a try. Will you be updating it sometime soon or shall I use the existing version?
Does the MouseDown event give you the tab number that was clicked on?
Keep an Integer of the current TabPanelIndex. If they haven’t saved when they click a new panel, move back to that TabPanelIndex and display the warning. If they have saved, update the Integer with the new TabPanelIndex.
I save the current panel number when switching into a panel, and set a flag when a change within the panel is made. Then, in the TabPanel’s Change event, I check if there are unsaved changes and if there are, force the panel back to its original value. So, from the user’s PoV, when trying to switch panel with unsaved changes they are just asked to save them, and the panel in view remains the same until they do.
So, just a bit of extra logic is all that’s needed.
I’ll post the updated code in the next days.
Thank you I look forward to trying it.
Yes I did wonder about that but didnt try as I feared the panel switching would cause screen flicker.I guess I should be bolder!
There’s no flicker, perhaps because any updating occurs only when the Change event has completed. I’m sort of surprised that Xojo didn’t do what they do in other cases, allow to to return True or False from the Change event handler to stop the panel change or allow it to proceed. But they don’t so one has to add this extra logic to make it work as desired in this instance. Don’t forget to clear your chnages flag, though, when the user does the save.
Those are additions done along the years. A feature request in Feedback might work for this addition…
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.