Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » TabCtrl » How to use TabBar CancelClose/WhenClose?
Re: How to use TabBar CancelClose/WhenClose? [message #46506 is a reply to message #46504] Wed, 18 May 2016 10:29 Go to previous messageGo to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Hi Lance,

Thank you for the help. Unfortunately, I can't get your sample to link.

But it did help me to find out why my gates wouldn't compile: I had it take a const Value& parameter instead of a Value.

So now it works.

But I found a bug on TabBar. The closing mechanism is based on the current highlighted tab under mouse. Which is fine, until you Prompt in CancelClose, like I do:

bool EditorManager::OnCancelClose(Value val) {
	int i = tabFiles.GetCursor();
	if (i == -1)
		return true;
	
	if (IsChanged(i)) {
		BeepQuestion();
		String fn = DeQtf(tabFiles[i].key.ToString());
		DUMP(tabFiles.GetHighlight());
		int save = PromptSaveDontSaveCancel("[ph The following file was changed since last save:&-|[* " + fn + "]&Would you like to save it?]");
		DUMP(tabFiles.GetHighlight());
		if (save == 1)
			Save(i);
		else if (save == -1)
			return true;
	}
		
	return false;
}


Between the two DUMPs, the highlight changes to -1. I tried this simple fix in TabBar.cpp:

void TabBar::MiddleDown(Point p, dword keyflags)
{
	if (highlight >= 0)
	{
		Value v = tabs[highlight].key;
		ValueArray vv;
		vv.Add(v);
		int highlightBack = highlight;
		if (!CancelClose(v) && ! CancelCloseSome(vv)) {
			Value v = tabs[highlightBack].key;
			// 2014/03/06 - FIRST the callbacks, THEN remove the tab
			// otherwise keys in WhenCloseSome() are invalid
			WhenClose(v);
			WhenCloseSome(vv);
			TabClosed(v);
			Close(highlightBack);
		}
	}
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Coloring tab
Next Topic: How to plot image in one tab based on TabCtrl
Goto Forum:
  


Current Time: Sun May 12 17:41:33 CEST 2024

Total time taken to generate the page: 0.01394 seconds