Button Insensitivity

Hello.

I’ve been working on an program that must run in both iOS and Android. I am new to Android.

I have some buttons that are in the corners of the screen and some that are in the middle of the screen. Those in the middle work fine. Those in the corners not so much. They do not seem to respond to touch most of the time. Everything works fine in the simulator and on iOS.

Are there areas on Android devices I should avoid? Am I too close to the edges?

Thank you for any hints.

-Bob

how are you doing your buttons? widgets? or rolled your own? if your own, what is the eventListener attached to? button background? which event.phase actions the button? There’s a number of things that could cause buttons to be less than perfectly responsive, but without seeing some code it’s hard to know!

Thank you for the quick response.

I’m using the button widgets for all the buttons. I have noticed (on another page of the app) that getting the event phase right makes a huge difference. 

Since you don’t mention it, I’ll assume there is nothing strange about putting buttons in the corners on an Android device.

I will see if making my own button makes any difference.

Thank you, again.

-Bob

I’ve noticed this also recently, but can’t seem to pinpoint the problem.  It might have to do with the size of the button

Thanks. Good to know I’m not hallucinating.

I’m going to try a couple of things and report back (Maybe tomorrow).

-Bob

Is it possible that because of position, you’re ‘sliding off’ the button before an “ended” event phase has occurred?

For the sake of experimentation, remove the ‘onEvent’ button handler and add a tap, rather than touch, handler manually after creation. And obviously take out the ‘event.phase’ evaluations.

As long as there’s no critical reason why you need to evaluate multiple event phases, I find these tend to be more responsive anyway.

Just as an FYI, widget.newButton supports three handlers:

onEvent

onPress

onRelease

We intercept the touch handler for the object and process the events ourselves inside the widget.newButton code. onPress triggers if we see a “began” phase on the object and you’ve defined this event. We will throw away moved, ended and such. You will get the touch event table, but only for began.

For onRelease it’s the same except you will only get the “ended” phase of the touch.

For onEvent, you basically get the full “touch” behavior. You cannot really setup a tap handler here.

Rob

I think I may have figured something out. 

The button was a “two-picture” type. I checked the dimensions of the picture and then made the dimensions of the button match. I also did not do AnchorX/Y = 0; I left things using the default center. I then got the button positioned where I want it. It appears to respond much more reliably now.

My guess is that the AnchorX/Y = 0 was causing the problem. Perhaps someone who knows more about how Corona works on Android (probably almost anyone other than me) could provide some more information. 

I am going to make the same change to my other problematic buttons and report back (tomorrow).

how are you doing your buttons? widgets? or rolled your own? if your own, what is the eventListener attached to? button background? which event.phase actions the button? There’s a number of things that could cause buttons to be less than perfectly responsive, but without seeing some code it’s hard to know!

Thank you for the quick response.

I’m using the button widgets for all the buttons. I have noticed (on another page of the app) that getting the event phase right makes a huge difference. 

Since you don’t mention it, I’ll assume there is nothing strange about putting buttons in the corners on an Android device.

I will see if making my own button makes any difference.

Thank you, again.

-Bob

I’ve noticed this also recently, but can’t seem to pinpoint the problem.  It might have to do with the size of the button

Thanks. Good to know I’m not hallucinating.

I’m going to try a couple of things and report back (Maybe tomorrow).

-Bob

Is it possible that because of position, you’re ‘sliding off’ the button before an “ended” event phase has occurred?

For the sake of experimentation, remove the ‘onEvent’ button handler and add a tap, rather than touch, handler manually after creation. And obviously take out the ‘event.phase’ evaluations.

As long as there’s no critical reason why you need to evaluate multiple event phases, I find these tend to be more responsive anyway.

Just as an FYI, widget.newButton supports three handlers:

onEvent

onPress

onRelease

We intercept the touch handler for the object and process the events ourselves inside the widget.newButton code. onPress triggers if we see a “began” phase on the object and you’ve defined this event. We will throw away moved, ended and such. You will get the touch event table, but only for began.

For onRelease it’s the same except you will only get the “ended” phase of the touch.

For onEvent, you basically get the full “touch” behavior. You cannot really setup a tap handler here.

Rob

I think I may have figured something out. 

The button was a “two-picture” type. I checked the dimensions of the picture and then made the dimensions of the button match. I also did not do AnchorX/Y = 0; I left things using the default center. I then got the button positioned where I want it. It appears to respond much more reliably now.

My guess is that the AnchorX/Y = 0 was causing the problem. Perhaps someone who knows more about how Corona works on Android (probably almost anyone other than me) could provide some more information. 

I am going to make the same change to my other problematic buttons and report back (tomorrow).