Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
"hitTestPoint" in "TOUCH" events, not "MOUSE" events — Gideros Forum

"hitTestPoint" in "TOUCH" events, not "MOUSE" events

PlatypusPlatypus Member
edited April 2013 in Game & application design
Guys,

In "button.lua" (in Gideros' included "Button" template):


the MOUSE function contains "hitTestPoint" (and "updateVisualState")
function Button:onMouseDown(event)
	if self:hitTestPoint(event.x, event.y) then
		self.focus = true
		self:updateVisualState(true)
		event:stopPropagation()
	end
end
but the TOUCH function doesn't.
function Button:onTouchesBegin(event)
	if self.focus then
		event:stopPropagation()
	end
end
Why is that?

I was going to use "onMouseDown" in my app, but maybe I should use "onTouchesBegin" instead - it seems to require less typing!
Kate's Catalogue of Travelling Theatre Centres :
Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Hello @Platypus
    Touch events require same hit test point as mouse events. Actually even little more typing as they have touch table:
    function SomeClass:onTouchesBegin(event)
    	if self:hitTestPoints(event.touch.x, event.touch.y) then
    		event:stopPropagation()
    	end
    end
    in Button class this is not required due to the fact that button already receives mouse event and touch event is only used to stop event propagation (everything underneath the button tree would not receive the event, a little optimization trick, that is not required anymore, since touch/mouse events were optimized).
  • @Ar2rsawseen,
    Thanks, mate.
    Kate's Catalogue of Travelling Theatre Centres :
    Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
    She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.
Sign In or Register to comment.