mousehit?

BlitzMax Forums/MaxGUI Module/mousehit?

D4NM4N(Posted 2006) [#1]
I want to detect a mouse hit

why cant i detect a mouse hit ie:
case EVENT_MOUSEDOWN
mhit1=mousehit(1)


Dreamora(Posted 2006) [#2]
If you want to use mousehit you must enable polled input, otherwise it won't work. And you must be on a gadget that does fire mousedown events at all (active panel, window, canvas)


tonyg(Posted 2006) [#3]
Check eventdata() for EVENT_MOUSEDOWN for the mouse button hit.
SuperStrict

Local MyWindow:TGadget=CreateWindow("Panel Example", 200,200,320,240)
Local MyPanel:TGadget=CreatePanel(110,30,80,80, MyWindow, PANEL_ACTIVE)
Local image1:TPixmap=LoadPixmap("Button_1.jpg")
Local image2:TPixmap=LoadPixmap("Button_2.jpg")
Local image:TPixmap = image1

Repeat
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
 Case EVENT_MOUSEDOWN	
		SetStatusText mywindow,"Mousebutton " + EventData() + " hit"
		Select EventData()
			Case 1
 			 image = image2
			
		End Select
  Default
     image=image1
   End Select
 SetPanelPixmap MyPanel , image , PANELPIXMAP_CENTER
 Flip 
Forever



Dreamora(Posted 2006) [#4]
MouseDown isn't the same as mousehit.
mouse hit counts the number of hits since the last call of it (it does not say if it has been pressed as some assume until they run into the well known "why does it return 0 on the second call" problem) so what you would need to do is raise a variable each time a mousedown is registred ... but thats a little pointless as this is exactly what BM itself already does with the mouse and keyboard buffer arrays for hit and down ^^


D4NM4N(Posted 2006) [#5]
Ahh, got it now, the mousedown event is a bit like mousehit, i was thinking it an event whenever the mouse was down, not just when its pressed.