Results 1 to 5 of 5

Thread: delay execution of mouse down event?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Hi,

    I want the code in the mouse down event to fire only if the button has been pressed for a certain length of time, like 1 second or so...

    I know about the time control but not sure how it would be used in this application.. I also know about the Sleep API function but that won't work because that would cause the button to stay pressed for the sleep time..

    Example code would be appreciated..

    Dan

  2. #2
    Guest
    Couldn't you put in the mouse down event a timer that is activated for the time you want it down for. Then put in the mouseup event to disable the timer and reset the time. This should stop the event if the user releases the mouse to fast, otherwise, the user will have to hold it down until the timer fires off.
    Hope that helps, of course, I didn't try it yet...lol

  3. #3
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    here is what hellswairth is talk about:


    Add 1 label and 2 timers
    Code:
    Private Sub Form_Load()
    Timer1.Interval = 2000
    Timer2.Interval = 2000
    Timer1.Enabled = False
    Timer2.Enabled = False
    End Sub
    
    Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Timer1.Enabled = True
    End Sub
    
    Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Timer2.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
    'code for mouse down event
    Timer1.Enabled = False
    End Sub
    
    Private Sub Timer2_Timer()
    'code for mouse up event
    Timer2.Enabled = False
    End Sub
    NXSupport - Your one-stop source for computer help

  4. #4
    Guest
    This method only involves 1 timer and 1 commandbutton:

    Code:
    Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Timer1.Interval = 2000
        Timer1.Enabled = True
    End Sub
    
    Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Timer1.Enabled = False
    End Sub
    
    Private Sub Timer1_Timer()
        Timer1.Enabled = False
        MsgBox "Mouse held down for two secs!"
    End Sub
    Try it...

    Enjoy!

  5. #5
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    but lets say that in the timer event, it said to change the back ground color, then if you disable the timer, the back ground is still what it was when you put your mouse down
    NXSupport - Your one-stop source for computer help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width