kpmiller@uokmax.ecn.uoknor.edu (Kent P Miller) (04/05/91)
I need some help desperately. I have a need to detect how long the mouse has been down. I have a control that when you press on the up arrow, the counter increments by 1. What I would like it to do is if you have held the mouse down on it for a second or so, it would increment by 5. I believe I have seen some code that does that in the past, but I'll be danged if I can remember where. Thanks for your support. Kent -- ----------------------- Kent Miller KENT@aardvark.ucs.uoknor.edu Bitnet -> KENT@uokucsvx
dweisman@umiami.ir.miami.edu (Ordinary Man) (04/06/91)
In article <1991Apr5.132205.28999@uokmax.ecn.uoknor.edu>, kpmiller@uokmax.ecn.uoknor.edu (Kent P Miller) writes: > I need some help desperately. > > I have a need to detect how long the mouse has been down. I have a control > that when you press on the up arrow, the counter increments by 1. What > I would like it to do is if you have held the mouse down on it for a second > or so, it would increment by 5. I believe I have seen some code that does > that in the past, but I'll be danged if I can remember where. When Get/Wait NextEvent reports mousedown, chek to see if theEvent.where lies in your control. If so, save the old theEvent.when, and compare this in a while StillDown loop to TickCount.. When TickCount goes past 60 or so ticks past the original event, a second has passed. Before this second has passed, you can increment by 1. Then after, you can inrement by 5. You should also call GetMouse to make sure the mouse stays in the control. Pascal code off the top of my head... -------------------------------------------------------------------------------- procedure ProcessControl(where:Point;when:longint); var inc:integer; begin GlobalToLocal(where); inc:=0; if PtInRect(where,YourcontrolRect) then begin while StillDown do begin if PtInRect(where,YourCotrolRect) then if TickCount-when < 60 then inc:=inc+1 else inc:=inc+5; GetMouse(where) end {while} end {if} end; {ProcessControl} This should do what you want, but this code hasn't been tested obviously. You get the idea... Dan -- /-------------------------------------------------------------------------\ | Dan Weisman - University of Miami - Florida | || || || || | |--------------------------------------------------| || || ||\ /|| | | INTERNET -----> dweisman@umiami.IR.Miami.edu | || || || | || | | BITNET -----> dweisman@umiami | ||||||| || | || | |-------------------------------------------------------------------------| | "The more I get to see, the less I understand..." - Triumph | \_________________________________________________________________________/