Page 1 of 1

Mouse how long pressed?

Posted: Wed Nov 26, 2014 6:54 pm
by Cyberity
Hello !

How can I get mouse press time so I want to know the milisecond of the mouse press time ! Not dll.

I would like a program like: If I press mouse until 1 sec its debug me 1000.

Re: Mouse how long pressed?

Posted: Wed Nov 26, 2014 7:26 pm
by Bisonte
An eventloop !

Code: Select all

OpenWindow(0, 100, 100, 200, 200, "Press Mouse in here")

CanvasGadget(0, 20, 20, 160, 160)
StartDrawing(CanvasOutput(0))
Box(0,0,200,200,0)
Box(2,2,186,186, #Red)
StopDrawing()

Repeat
  
  Event = WaitWindowEvent()
  
  If Event = #PB_Event_CloseWindow
    Quit = 1
  EndIf
  
  If Event = #PB_Event_Gadget
    If EventGadget() = 0
      If EventType() = #PB_EventType_LeftButtonDown
        Timer = ElapsedMilliseconds()
      EndIf
      If EventType() = #PB_EventType_LeftButtonUp
        Debug "Leftbutton hold for ca. " + Str(ElapsedMilliseconds() - Timer) + "ms"
      EndIf
    EndIf
    
  EndIf
  
  
Until Quit > 0