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 » U++ Widgets - General questions or Mixed problems » Changing mouse icon with MouseEvent
Changing mouse icon with MouseEvent [message #54793] Wed, 16 September 2020 18:59 Go to next message
koldo is currently offline  koldo
Messages: 3196
Registered: August 2008
Senior Veteran
Hi all

I wanted to change mouse icon when clicking, but I cannot.
Please tell me what I am doing wrong. Thank you!

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct App : TopWindow {
	virtual Image MouseEvent(int event, Point, int, dword) {
		if ((event & Ctrl::BUTTON) == Ctrl::LEFT && (event & Ctrl::ACTION) == Ctrl::DOWN) 
			return Image::Hand();
		return Image::Arrow();
	}
};

GUI_APP_MAIN
{
	App().Run();	
}


Best regards
Iñaki

[Updated on: Wed, 16 September 2020 19:37]

Report message to a moderator

Re: Changing mouse icon with MouseEvent [message #54800 is a reply to message #54793] Thu, 17 September 2020 09:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12716
Registered: November 2005
Ultimate Member
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct App : TopWindow {
	virtual Image MouseEvent(int event, Point, int, dword) {
		if (event == CURSORIMAGE) 
			return Image::Hand();
		return Image::Arrow();
	}
};

GUI_APP_MAIN
{
	App().Run();	
}
Re: Changing mouse icon with MouseEvent [message #54802 is a reply to message #54800] Thu, 17 September 2020 11:22 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3196
Registered: August 2008
Senior Veteran
Thank you Mirek

Unfortunately the code always shows a hand.
Next option works, although it probably could be improved:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct App : TopWindow {
	bool showHand = false;
	
	virtual void LeftDown(Point, dword) 	{showHand = true;}
	
	virtual void LeftUp(Point, dword) 	{showHand = false;}
	
	virtual Image CursorImage(Point, dword) {
		if (showHand)
			return Image::Hand();
		else
			return Image::Arrow();
	}
};

GUI_APP_MAIN
{
	App().Run();	
}


Best regards
Iñaki
Re: Changing mouse icon with MouseEvent [message #54803 is a reply to message #54802] Thu, 17 September 2020 11:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12716
Registered: November 2005
Ultimate Member
koldo wrote on Thu, 17 September 2020 11:22
Thank you Mirek

Unfortunately the code always shows a hand.
Next option works, although it probably could be improved:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct App : TopWindow {
	bool showHand = false;
	
	virtual void LeftDown(Point, dword) 	{showHand = true;}
	
	virtual void LeftUp(Point, dword) 	{showHand = false;}
	
	virtual Image CursorImage(Point, dword) {
		if (showHand)
			return Image::Hand();
		else
			return Image::Arrow();
	}
};

GUI_APP_MAIN
{
	App().Run();	
}


This works.

Note that you have not said in the previous post what you really want to achieve... Smile

Simpler solution:

struct App : TopWindow {
	virtual Image MouseEvent(int event, Point, int, dword) {
		if (event == CURSORIMAGE && GetMouseLeft()) 
			return Image::Hand();
		return Image::Arrow();
	}
};
Re: Changing mouse icon with MouseEvent [message #54804 is a reply to message #54803] Thu, 17 September 2020 12:47 Go to previous message
koldo is currently offline  koldo
Messages: 3196
Registered: August 2008
Senior Veteran
Solved. Thank you Mirek!

Best regards
Iñaki
Previous Topic: [GlCtrl] Integration and use of Glad loader instead of Glew
Next Topic: Background color of StaticText or EditString
Goto Forum:
  


Current Time: Sun Sep 27 21:13:58 CEST 2020

Total time taken to generate the page: 0.01120 seconds