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 » FileSel&FileList, Path » FileSel ExecuteSaveAs replace file prompt bug
FileSel ExecuteSaveAs replace file prompt bug [message #16280] Thu, 05 June 2008 19:57 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
When I use FileSel::ExecuteSaveAs with the Asking option, when trying to replace an existing file it will prompt you to confirm, but the file list will go into edit mode if you wait about a second and don't answer the prompt.

I think that double clicking on a control which allows in place editing should not set of any edit event. Only if the two clicks are made in an interval larger than the double click register time should the edit event fire, so I think this should be changed at the level of FileList.

I tried to kill the timer event which calls StartEdit on double click, but it did not work.

There is also a fix specially for FileSel which I'm using right now.

Add to FileList:
	bool		IsRenaming()						 { return renaming; }

void FileList::StartEdit() {
	if (!renaming)
		return;
	Rect r = GetItemRect(GetCursor());
	const File& cf = Get(GetCursor());
	Font f = cf.font;
	int fcy = f.Info().GetHeight();
	r.left += iconwidth + 2;
	r.top += (r.Height() - fcy - 4) / 2;
	r.bottom = r.top + fcy + 2;
	edit.SetRect(r);
	edit.SetFont(cf.font);
	edit = cf.name.ToWString();
	edit.Show();
	edit.SetFocus();
}

Add to FileSel::Finish():
...
		if(asking)
			if(mode == SAVEAS) {
				bool b = list.IsRenaming();
				list.Renaming(false);
				if(!ff.IsEmpty() && !PromptOKCancel(p + t_(" already exists.&Do you want to continue ?")))
				{
					list.Renaming(b);
					return;
				}
			}
			else
...
Re: FileSel ExecuteSaveAs replace file prompt bug [message #16286 is a reply to message #16280] Fri, 06 June 2008 10:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
Thanks, this is stupid bug indeed.

I have resolved it with this simpler/cleaner fix:

void ColumnList::DoLeftDown(Point p, dword flags) {
	selclick = false;
	int i = GetDragColumn(p.x);
	if(i >= 0) {
		ci = i;
		dx = p.x - GetColumnCx(0) * (i + 1);
		mpos = p.x;
		SetCapture();
		Refresh(mpos - dx, 0, 1, GetSize().cy);
		SyncInfo();
	}
	else {
		int i = GetItem(p);
		if(i >= 0 && i < GetCount() && multi && IsSel(i))
			selclick = true;
		else
			DoClick(p, flags);
	}
}

void ColumnList::LeftDown(Point p, dword flags) {
	DoLeftDown(p, flags);
}


void ColumnList::LeftDouble(Point p, dword flags) {
	DoLeftDown(p, flags);
	WhenLeftDouble();
}


(Moral of the story - be careful with calling virtual methods...)

Mirek
Re: FileSel ExecuteSaveAs replace file prompt bug [message #16288 is a reply to message #16286] Fri, 06 June 2008 10:58 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Ah yes, now I understand while it behaved this way. Good fix, much cleaner this way and directly at the source. Thanks!

Should we get that bug-log running?
Previous Topic: FileSel bug when displaying Han characters
Next Topic: FindFile Problem
Goto Forum:
  


Current Time: Tue Mar 19 08:53:11 CET 2024

Total time taken to generate the page: 0.01795 seconds