Good evening my good mates I am Anshumaan Kumar and I want to create a button in my application which can turn off by itself after the set time even if the user is holding the button. I know it is easy but even after two days I am not able to create it. I however tried to use a clock and two variables. This is what I was doing :
The button is initially at OFF position.
User touched the button and it is set to ON position.
The first variable used as a flag is set up and starts a clock which increments another variable
which after the set time is used to turn the button back to OFF position, even if the user is holding the button.
Apart from this mechanism the user should be able to touchup and touchdown the button to change the state.
Sounds pretty simple if seen from the coding angle. I have done this in many embedded applications but I am not able to perform this mechanism although the touchUP and touchDown functions of the app inventor has helped me to achieve the last part of my requirement any help would be Greatly Appreciated.
I have not shown the blocks as I have done many edits to them and they are not functioning as I have stated so to avoid confusion I have not posted them.
Anshumaan..
If you call the actions in the "touchUp" event with a clock timer, the worst that can happen is that the same actions will be called again when the user actually does "touchUp".
To my knowledge, there is no method available to prevent the touchUp event, although you could set a variable flag when the clock timer runs, and test for this in the touchUp event.
Well yes the thing here is that the touch up and touch down of the button should work as normal but if the user tries to touchup the button for too long(he may be dancing or maybe he forgets to remove his finger from the button ) the button will go to off state...This is exactly what I was trying to do....
Sorry for the late replies I was trying to solve this....
TIMAI2 - Thanks for the reply bud let me try your solution and let you know how that worked out with blocks this time.
Patryk_F - Thanks for the reply... Let me just check which idea suits me more Thanks for the replies all of you...
Anshumaan..
Very Interesting solution you have for my problem I used this and to my wonders this is exactly what I was trying to do all along.. Well maybe I think that I need more practice with app inventor.. I was trying to use the clock to increment a variable via the clock and I forgot that clock already does the counting I don't need to use a separate variable for that... I learnt that much today.. Thanks again... This is exactly what I was trying to do...
Also Thank you good sir Patryk_F your solution also works flawlessly as well...
Thank you again for the Good solutions I sure learnt a new thing about the app inventor today thank you guys
Anshumaan.....