Mouse on gadget

BlitzMax Forums/BlitzMax GUI Programming/Mouse on gadget

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Ziggy: You can place a button on a slightly larger active panel to track where the mouse is and by using the EVENT_MOUSEENTER and EVENT_MOUSELEAVE commands, set the pointer when entering a gadget (or more specifically, its surrounding panel).

Have a look at this example:

Global wndMain:TGadget = CreateWindow("Test Window",100,100,400,300,Null,15)

	Global gadWindowPanel:TGadget = CreatePanel(0,0,ClientWidth(wndMain),ClientHeight(wndMain),wndMain,PANEL_ACTIVE)

		Global gadButtonPanel:TGadget = CreatePanel(5,5,110,30,gadWindowPanel,PANEL_ACTIVE)
		
			Global gadButton:TGadget = CreateButton("Test Button",5,5,100,20,gadButtonPanel)

'The larger the panel border, the more reliably the pointer will change when mouse moves over it quickly.
'A border of about 5 seems about right for most uses.

Repeat

	Select WaitEvent()
	
		Case EVENT_WINDOWCLOSE;End
		
		Case EVENT_MOUSEENTER
		
			Select EventSource()
			
				Case gadWindowPanel;SetPointer(POINTER_NORMAL)
				Case gadButtonPanel;SetPointer(POINTER_HAND)
				
			EndSelect
	
	EndSelect

Forever


A bit of a pain, but it's better than nothing.


Seb