tabStrip PropertyChange

Does anyone have a way to interrupt a tabStrip change from happening?
I have a tabstrip with Navigation Mode = Disabled.
When the user clicks another tab, I want to prompt the user to save their data before the tab change takes place.

I’ve tried using a propertyChange script:

if event.propertyName == 'selectedTab':
	userResponse = system.gui.confirm('Do you want to save your edits before leaving "%s"'%event.oldValue, 'Save?', False)
	if userResponse:
		# save data OR prevent the tab from changing so user can decide...
	else:
		pass # allow the tab to change

The tab change takes place before the message is displayed.
I’ve also messed around with mousePressed and mouseClicked but I can’t find a way to prompt the user before the tab change has already completed.

TIA for suggestions.

What do you mean by “the tab change has already completed”? If you have Nav Mode disabled, the tabstrip isn’t going to open any windows for you, that’s all that’s disabled.
Consider adding a custom string property to your tabstrip, something like “acceptedTab”, and use that in all of your bindings instead of selectedTab. Your propertyChange script would then look like this:

if event.propertyName == 'selectedTab' and event.source.acceptedTab != event.source.selectedTab:
	userResponse = system.gui.confirm('Do you want to save your edits before leaving "%s"'%event.oldValue, 'Save?', False)
	if userResponse:
		# prevent the tab from changing so user can decide...
		event.source.selectedTab = event.source.acceptedTab
	else:
		pass # allow the tab to change
		event.source.acceptedTab = event.source.selectedTab
1 Like

Thank you.
Changing the bindings to a custom property does what I wanted.