Re: sir i have boolean variable i want if mouse is clicked on it...

2003-12-27 Thread Al S
There are some limitations to this approach.
The mechanical action of the switch can only be Switch Until Released
or Latch Until Released.  For any other mechanical action, you can
tell when it was pressed or when it was released, but not both.  If
you need to use local variables for your button, you can only use
Switch Until Released (locals don't work with latch actions).
Switch Until Released and Latch Until Released limit the switch to a
momentary-contact switch.  If you need a toggle switch, you need an
event structure.
Using an event structure gives you a lot more flexibility.  You can
use a toggle switch.  You can check if the button was held while
turning it either off or on or both.



Re: sir i have boolean variable i want if mouse is clicked on it...

2003-12-24 Thread tmh
For those who don't have the ability to create event structures, it's
pretty easy to do the old-fashioned way. Create a while loop with a
shift register and initialise it with the ms tick count. Each time
round the loop, check the Boolean and if it is True, keep the existing
shift register value, otherwise update the register with the current
ms tick count. Compare the current ms tick count with the original
value plus 2000 and if it's greater, exit the loop and write True to
the second Boolean. The loop only needs to cycle every 100 ms or so so
it's hardly a big drain on your processor...



Re: sir i have boolean variable i want if mouse is clicked on it...

2003-12-23 Thread Al S
Ben:
I didn't go through your code, but once your LED goes on, it stays on,
even if the next time you press the button it's for less than 2
seconds.



Re: sir i have boolean variable i want if mouse is clicked on it...

2003-12-23 Thread Ben
You are correct!

The orignal question was not exaclty clear on what should happen to
clear the output boolean.

My example simply toggles the state of the output boolean when the
control boolean is held down for more than 2 seconds.

Ben



Re: sir i have boolean variable i want if mouse is clicked on it...

2003-12-23 Thread Al S
Nirmal:
I think the question asked how to indicate that a button was held down
for more than 2 seconds.  Your example just lights the LED two seconds
after the button was pressed and doesn't check how long the button was
held down.  To see how long a button is held down, you should use an
event structure.  Look at Ben's example or my example.