|
#1
|
|||
|
|||
|
When clicking the screen to select the application from the menu, that click seems to be carried through and counts as a click inside the now running application. That causes a button to be pressed that was unintentional.
I need to clear any outstanding clicks (or other events) once the application has started. Any thoughts please? |
| Advertisement | [Remove Advertisement] |
|
|
|
|
#2
|
||||
|
||||
|
Hm, I don't have this trouble. How do your main loop read for the click?
One way to "hard" clear it is by simply adding this function: Code:
--Clear event que function function clearQue() os.wait(50) while (control.read()==1) do control.isTouch() end end
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it! Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it. Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^ |
|
#3
|
|||
|
|||
|
Thanks for responding Habhome. I have been using the Apeopex routines. I can only assume that maybe I keep the mouse/finger on the screen too long. It is a definite problem because I can avoid it by clicking in the menu in a position where my Start button will not appear.
I will certainly give your routine a try, many thanks. |
|
#4
|
||||
|
||||
|
Wow, I've seen some troubles with the event queue, but none involving clicks before the app even started..
Could you post the code that causes this, or even better, the whole app? ps. Great idea putting it into a function Habhome ![]() EDIT That's certainly an indication that a touch event is still in the queue, I'm really hoping that your app's code will provide some more insight on this.. |
|
#5
|
|||
|
|||
|
The following code extract is where the problem occurs. It is NOT consistent, but if the menu entry for this program is clicked and the click is over where the Start Button will appear, gStart [sometimes] becomes true and passes the test in the repeat loop. Perhaps it is to do with the length of click or a movement once clicked. I can see nothing wrong with the code, it works otherwise. The provided function to cure does seem to work.
Over to you... Any other comments always welcome. Code:
gStart=false
OnTouchClick = nil
function TouchEvent(x,y)
local Changed, Col, Row = false, gCurOldC, gCurOldR
--Check Start button
if (x>4) and (x<47) and (y>210) and (y<244) then
print("Start pressed")
gStart = not gStart
ReverseButton()
Box[x] = Box[x] +-1
end
... more testing code is here
end
IN HERE A CUTDOWN VERSION OF Apeopex (without user buttons)
function GetEvent()
if (control.read(1) == 1) then
if (control.isTouch() == 1) then
local x, y = touch.pos();
if (touch.down() == 1) then
if (OnTouchDown ~= nil) then
OnTouchDown(x,y);
end;
elseif (touch.up() == 1) then
if (OnTouchUp ~= nil) then
OnTouchUp(x,y);
end;
elseif (touch.click() == 1) then
if (OnTouchClick ~= nil) then
OnTouchClick(x,y);
end;
elseif (touch.move() == 1) then
if (OnTouchMove ~= nil) then
OnTouchMove(x,y);
end;
end;
...
...
end
OnHomeClick = ExitApp
OnTouchClick = TouchEvent
--*****************************
repeat
GetEvent()
if gStart then
Update()
end
until (gExit == true)
|
|
#6
|
||||
|
||||
|
Do you declare the x and y variables in the start of your code? And if you don't try to do that by setting them to a value where a click wouldn't do anything, -1 perhaps.
Code:
x = -1 y = -1
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it! Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it. Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^ |
|
#7
|
|||
|
|||
|
The only 'declaration' is in the GetEvent (Apeopex)...
Code:
local x, y = touch.pos(); I think you are suggesting that maybe they have a random value at that point. Thank you for making the point. I will certainly try that, especially as I have been too loose with such matters due to eagerness. Normally I declare everything, but Lua seems very forgiving, nay, too forgiving. |
|
#8
|
||||
|
||||
|
The program doesn't start before you lifted your finger from the screen, so it can't be a hold or a move from selecting the program from the menu.
I'm thinking there are some events left in the queue from the last time this program ran. Does the exit button happen to be at the same place as the Start button? For example when a touch.down exits the app, a touch.click at that same place is still in the queue. Last edited by Brett_val; 05-18-2010 at 07:25 AM. |
|
#9
|
|||
|
|||
|
Thanks Brett_val. Unfortunately no, the exit is done by HomeClick as suggested by Habhome, so it is not a screen position.
Today I removed the routine suggested by Habhome and it still has not gone wrong, embarrassingly. You may have a clue with your suggestion because I do tend to do small code changes and then re-run, so I run very often. Perhaps something did get left, I hasten to add, if I did not say so, that this is on the simulator, I have not tried that problem live because it was intermittent. I hope this was not a red herring or fluke. |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 03:56 PM.













Linear Mode
