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 » Developing U++ » U++ TheIDE and Library: Releases and ChangeLogs » Ctrl::OverrideCursor
Ctrl::OverrideCursor [message #9219] Sun, 22 April 2007 09:45 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
static Image Ctrl::OverrideCursor(const Image& m);

Overrides the image of mouse cursor. You should end the override by calling it again with return value as argument...

Mirek
Re: Ctrl::OverrideCursor [message #14319 is a reply to message #9219] Fri, 22 February 2008 14:14 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Hi,

Ctrl::OverrideCursor() does not seem to react immediately (at least on Vista) but instead requires control to be returned to the system. I added SetMouseCursor(m) call to the CtrlMouse.cpp as follows and got immediate response:

Image Ctrl::OverrideCursor(const Image& m)
{
Image om = CursorOverride();
CursorOverride() = m;
DoCursorShape();
SetMouseCursor(m); // Added by tom
return om;
}

If you think it does not mess up anything else in UPP, please add it to the source. (The reason for immediate response requirement is that I need to show a wait cursor when processing some lengthy user mouse input requests.

// Tom
Re: Ctrl::OverrideCursor [message #14348 is a reply to message #14319] Sat, 23 February 2008 10:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Fri, 22 February 2008 08:14

Hi,

Ctrl::OverrideCursor() does not seem to react immediately (at least on Vista) but instead requires control to be returned to the system. I added SetMouseCursor(m) call to the CtrlMouse.cpp as follows and got immediate response:

Image Ctrl::OverrideCursor(const Image& m)
{
Image om = CursorOverride();
CursorOverride() = m;
DoCursorShape();
SetMouseCursor(m); // Added by tom
return om;
}

If you think it does not mess up anything else in UPP, please add it to the source. (The reason for immediate response requirement is that I need to show a wait cursor when processing some lengthy user mouse input requests.

// Tom


Well, this is really weird, as DoCursorShape calls SetMouseCursor too...

I have tested with this code, without proposed patch:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct App : TopWindow {
	virtual void LeftDown(Point, dword) {
		Image m = OverrideCursor(CtrlImg::exclamation());
		Sleep(1000);
		OverrideCursor(m);
		Sleep(1000);
	}
};

GUI_APP_MAIN
{
	App().Run();
}


and everything seems to work OK (WinXP).

Mirek
Re: Ctrl::OverrideCursor [message #14351 is a reply to message #14348] Sat, 23 February 2008 11:57 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Sorry, I was inaccurate in my explanation. The problem requires that the OverrideCursor() is called from a context menu callback function to NOT to work. (I only thought of it as being a mouse operation as I used the mouse right clicking to open the context menu.)

Anyway, my fix does not appear to work on Linux as SetMouseCursor can not be called in static member funtion OverrideCursor without an object.

The reason the DoCursorShape does not work in this context is probably because the DoCursorShape requires an existing "mouseCtrl" which is not true in this case. So, I guess a proper fix would require a way to bypass a nonexistent mouseCtrl for an overridden mouse cursor. Or what do you think Mirek?

// Tom
Re: Ctrl::OverrideCursor [message #14355 is a reply to message #14351] Sat, 23 February 2008 15:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Sat, 23 February 2008 05:57

Sorry, I was inaccurate in my explanation. The problem requires that the OverrideCursor() is called from a context menu callback function to NOT to work. (I only thought of it as being a mouse operation as I used the mouse right clicking to open the context menu.)

Anyway, my fix does not appear to work on Linux as SetMouseCursor can not be called in static member funtion OverrideCursor without an object.

The reason the DoCursorShape does not work in this context is probably because the DoCursorShape requires an existing "mouseCtrl" which is not true in this case. So, I guess a proper fix would require a way to bypass a nonexistent mouseCtrl for an overridden mouse cursor. Or what do you think Mirek?

// Tom



I think you should provide a testcase to demonstrate the problem Wink

(if there is no mouseCtrl, it means that mouse cursor is over non-U++ window, so U++ is not responsible for its shape... or demonstrate with testcase why it should be.... Smile

Mirek
Re: Ctrl::OverrideCursor [message #14359 is a reply to message #14355] Sat, 23 February 2008 17:21 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
OK, here's the testcase. Today I'm on Linux and therefore I have no idea what happens when this is taken on Windows.

Anyway, on Linux none of the context menu callbacks work. The WaitCursor works neither on the context menu callback nor directly in MiddleUp. OverrideCursor works on LeftUp, but fails on context menu callback.


#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class Testcase : public TopWindow{
	
public:
	typedef Testcase CLASSNAME;
	
	Testcase(){

	}

	virtual void ContextMenu(Bar &bar){
		bar.Add(t_("Lengthy process with OverrideCursor..."),THISBACK(LengthyProcess1));
		bar.Add(t_("Lengthy process with WaitCursor..."),THISBACK(LengthyProcess2));
	}

	virtual void LengthyProcess1(){
		// Not working on Linux:
		Image cursor=OverrideCursor(Image::Wait());
		Sleep(1000);
		OverrideCursor(cursor);
	}

	virtual void LengthyProcess2(){
		// Not working on Linux:
		WaitCursor waitcursor;
		Sleep(1000);
	}

	virtual void RightUp(Point p, dword keyflags){
		MenuBar::Execute(THISBACK(ContextMenu));
	}

	virtual void LeftUp(Point p, dword keyflags){
		// Working OK on Linux:
		Image cursor=OverrideCursor(Image::Wait());
		Sleep(1000);
		OverrideCursor(cursor);
	}

	virtual void MiddleUp(Point p, dword keyflags){
		// Not working on Linux:
		WaitCursor waitcursor;
		Sleep(1000);
	}

};

GUI_APP_MAIN
{
	Testcase().Run();
}


I think mouseCtrl might be null even though it should have a value. At least I can see the cursor on top of the Testcase window but still have no control over it using the above methods.

Just out of curiosity, which of the four cases work for you in XP? (When I get back to work on monday, I can test it on Vista.)

// Tom
Re: Ctrl::OverrideCursor [message #14374 is a reply to message #14359] Sun, 24 February 2008 09:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
In XP, all works except LengthyProcess1.

So I guess it will rather have something to do with X11 message queue... (missing Sync?). Will investigate soon.

Mirek
Re: Ctrl::OverrideCursor [message #14380 is a reply to message #14374] Sun, 24 February 2008 17:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
OK, found the cause (there is transitional state after menu popup when there is no mouseCtrl), fixed. Unfortunately, fixes are too scaterred to post here for checking, you have to wait for next release...

Tested with XP & Linux, all cases in testcase now OK.

Mirek
Re: Ctrl::OverrideCursor [message #14409 is a reply to message #14380] Mon, 25 February 2008 18:24 Go to previous message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
OK! Now everything in this testcase works on both Vista x64 and Kubuntu Linux. Thanks Mirek!

// Tom
Previous Topic: SDL updated from 1.2.12 to 1.2.13
Next Topic: to_string, to_wstring
Goto Forum:
  


Current Time: Thu Mar 28 16:22:18 CET 2024

Total time taken to generate the page: 0.02813 seconds