Hi there,
when using widget.newButton() for my buttons I notice delays when a function is called by way of using “onRelease” but can not really tell why and what is causing it.
Example Code:
-- draw "back" button
local backButton = widget.newButton{
default="images/back.png",
over="images/back\_down.png",
width=34, height=34,
onRelease = gotoMainMenu -- event listener function
}
backButton.x = screen.left + 35
backButton.y = screen.bottom - 30
backButton.alpha = 0 -- alpha will be set to 1 later on in the code
Once the button is pressed its state is changed from “default” to “over”. Once the button is released, the “gotoMainMenu” function us called. Pretty easy code there.
I am using buttons in several game screens (e.g. configuration, selection of game mode, etc.). I noticed that in some cases pressing a button and releasing it will not immediately call the “onRelease” function but rather requires a third or half of a second to pass until the function is actually called. It could as well be that the relevant “onRelease” function is called but the code within that function is executed with some delay. I noticed this due to some transitions taking place (menu items moving in and out of the screen). The new screen which is supposed to show once the button is released does not show up immediately but only some fractions of a second later.
I have no idea why this is happening and it does not happen on all of my screens where buttons are used. The delay is noticeable and I would like to get rid of it. By the way, this is more evident on a real device than in the simulator.
Has anyone else experienced the same and has a solution?
Jens [import]uid: 101883 topic_id: 31005 reply_id: 331005[/import]