Button Down Time - OI 7.1.1 (OpenInsight 32-Bit)
At 28 MAY 2005 08:17:57PM Don Muskopf wrote:
Does anyone know how to measure the amount of time a mouse button is being held down? I don't mean the elapsed time between, say, a buttondown and buttonup. Rather, a way to periodically measure how long a button has remained down, and then if it has remained down more than a specified amount of time (say 500ms), take some action.
Any suggestions would be appreciated, thanks.
Don Muskopf
At 01 JUN 2005 04:31AM Oystein Reigem wrote:
Don,
What about a timer event that checks stuff periodically, say each 50 ms?
I don't know how to check the state of a pushbutton (or pushbmp) directly. Perhaps somebody else can. If so you might have a solution.
But if that is not possible, perhaps the button itself can set some global value, e.g, a user defined property, when it's pressed and released. Then the timer handler can check that global value. But for this alternative you need BUTTONDOWN and BUTTONUP events. By default the only mouse event for a pushbutton is the CLICK event. Perhaps BUTTONDOWN and BUTTONUP can be enabled with the Event Designer (or whatever it's called).
If BUTTONDOWN and BUTTONUP can't be enabled for pushbuttons, you might use a bitmap instead of a button, and the BUTTONUP and BUTTONDOWN event of the window itself, because the window has such events, and they run when a bitmap is clicked. Design the bitmap to look like a button. Have a different bitmap for the pressed state, and let the BUTTONUP and BUTTONDOWN handlers change between the two images. But a bitmap will not be like a button in all ways.
- Oystein -
At 01 JUN 2005 03:23PM Don Muskopf wrote:
Oystein,
Thanks for your reply. I guess how to check the state of a pushbutton is the knowledge that I'm really missing.
Let's look at a possible example application for this:
Click a button to view a picture. Click the button again to view the next picture. Hold the button down to continuously scroll through the pictures. Let go of the button to stop scrolling through the pictures. Of course, we could do the same thing with calendar months, etc.
Obviously, the CLICK is easy. The repetition to scroll through the pictures can be done by looping and checking a user defined property on a BUTTONUP to exit from the a loop. The hard part for me is not beginning a loop immediately upon a BUTTONDOWN, but only after the button has been down for a certain period of time. That is, if the button is not down for the specified period of time, ignore the loop because it must be a normal CLICK.
I guess it also gets messy because BUTTONUP and BUTTONDOWN are intertwined with CLICK.
At 02 JUN 2005 06:32AM Oystein Reigem wrote:
Don,
] The hard part for me is not beginning a loop immediately upon a BUTTONDOWN, but only after the button has been down for a certain period of time. That is, if the button is not down for the specified period of time, ignore the loop because it must be a normal CLICK.
Let the loop indeed start immediately upon a BUTTONDOWN, but at BUTTONDOWN also save the current time, and in the loop check if enough time has passed to start acting.
- Oystein -
At 03 JUN 2005 09:47AM Don Muskopf wrote:
Oystein,
Thanks for the tip. It did get me started in the right direction. I'm finding that I need at least two loops to get this to work. One to keep track of the time, the other nested loop to execute the repetitive process. It's not fully debugged yet, but I'm getting there.
Don
At 03 JUN 2005 10:09AM Ray Chan wrote:
Don,
You'll find that Oystein is truly a creative problem-solver.
He helped me greatly when we went through our conversion from Arev to OI.
Good luck on your journey. I'm sure that you'll have fun.
Ray
At 03 JUN 2005 05:07PM Don Muskopf wrote:
Thanks Ray. I'm already having fun!