Button only sometimes fires event handler

Hi there,

I’m having an odd problem with widget buttons.

Sometimes, if I tap near the bottom of them on a device (particularly on small buttons on a small screen), the “over” state of the button is displayed but my event handler doesn’t fire.

Code for the event handler:

function handleButtonEvent(event) local phase = event.phase local btn = event.target; if ButtonsHandler:getLockLevel() \< btn.lockLevel then &nbsp; &nbsp; if "began" == phase then -- Do nothing elseif "moved" == phase then local sv = ButtonsHandler:getScrollerToPassFocusTo(); if (sv ~= nil) and (btn.inScrollView == true) then local dx = math.abs( event.x - event.xStart ) -- Get the x-transition of the touch-input local dy = math.abs( event.y - event.yStart ) -- Get the y-transition of the touch-input if dy \> 8 then &nbsp; &nbsp; sv:takeFocus( event ); end end elseif "ended" == phase then local onRelease = btn.oRel; if onRelease then result = onRelease( event ); end end end return result; end -- Then an example of a typical function I've passed as the btn.oRel function would be simply: function handleButtonTap(evt) print("BUTTON TAPPED"); end

Has anyone else experienced this?

Thanks,

Ian

Hi @keystagefun,

This doesn’t sound familiar. Which type of button event listener are you using? onPress, onRelease, or onEvent? Or, are you using multiple of these? Are you doing something “unusual” like scaling the buttons or nesting them deep in subgroups or something? Also, I’m not sure what you’re doing with that “oRel” property and such… one handler should be sufficient for most cases.

Take care,

Brent

Hi @keystagefun,

This doesn’t sound familiar. Which type of button event listener are you using? onPress, onRelease, or onEvent? Or, are you using multiple of these? Are you doing something “unusual” like scaling the buttons or nesting them deep in subgroups or something? Also, I’m not sure what you’re doing with that “oRel” property and such… one handler should be sufficient for most cases.

Take care,

Brent