Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another Mouse Issue?
#3
My mouse routine without double or triple clicks, which I'll probably add tomorrow.

Code: (Select All)
Type mousevar
    mx As Integer ' Row.
    my As Integer ' Column.
    wh As Integer ' Wheel.
    lb As Integer ' Left Button.
    rb As Integer ' Right Button.
    lb_status As Integer ' Left Button Status.
    rb_status As Integer ' Right Button Status.
    CursorStyle As Integer ' 0 Default, 1 Link style. (Hand).
    mousekey As String ' Auto Keyboard Input.
End Type
Dim m As mousevar

Sub mouse (m As mousevar)
    ' Local vars: i%,j%
    Static oldmx As Integer, oldmy As Integer
    If m.wh Then m.wh = 0
    While _MouseInput
        m.wh = m.wh + _MouseWheel
    Wend
    m.mx = _MouseX
    m.my = _MouseY
    m.lb = _MouseButton(1)
    m.rb = _MouseButton(2)
    Select Case m.lb
        Case 0
            Select Case m.lb_status
                Case -2
                    m.lb_status = 0 ' The clicked event and the release triggered any event structured to occur on release.
                Case -1
                    m.lb_status = -2 ' The clicked event triggered any event structured to occur when the button is released.
                Case 0
                    ' Button has not been pressed yet.
                Case 1
                    m.lb_status = -1 ' Rare but button was released before the next required cycle, so cycle is continued here.
                Case 2
                    m.lb_status = 0 ' The drag event is over because the button was released.
            End Select
        Case -1
            Select Case m.lb_status ' Note drag is determined in the text highlighting routine.
                Case -1
                    ' An event occurred and the button is still down.
                    If oldmx <> m.mx Or oldmy <> m.my Then m.lb_status = 2 ' Drag.
                Case 0
                    m.lb_status = 1 ' Left button was just pressed.
                Case 1
                    m.lb_status = -1 ' The button is down and triggered any event structured to occur on initial press.  The status will remain -1 as long as the button is depressed.
            End Select
    End Select
    Select Case m.rb
        Case 0
            Select Case m.rb_status
                Case -2
                    m.rb_status = 0 ' The clicked event and the release triggered any event structured to occur on release.
                Case -1
                    m.rb_status = -2 ' The clicked event triggered any event structured to occur when the button is released.
                Case 0
                    ' Button has not been pressed yet.
                Case 1
                    m.rb_status = -1 ' Rare but button was released before the next required cycle, so cycle is continued here.
                Case 2
                    m.rb_status = 0 ' The drag event is over because the button was released.
            End Select
        Case -1
            Select Case m.rb_status
                Case -1
                    ' An event occurred and the button is still down.
                Case 0
                    m.rb_status = 1 ' button was just pressed.
                Case 1
                    m.rb_status = -1 ' The button is down and triggered any event structured to occur on initial press.  The status will remain -1 as long as the button is depressed.
            End Select
    End Select
    oldmx = m.mx: oldmy = m.my
End Sub

Multiple left clicks an be handled with a timer. Timer starts when the left button is pressed. If the button is released within the time, a flag is set to count 1. If not, no flag. If the flag was set the timer now tracks no-click time. If that set time, say .1 expires, the flag is canceled. The flag can be increased to some max like 3 for a triple click. Of course we could also just count click and release events during a .2-sec period. Get 3 click cycles completed and your triple clicked!

I'll come back and update the code if I do add that to this routine tomorrow. I have a new graphics WP project I'm using this one in, but I haven't added double click to highlight one word or triple click to highlight the line, yet.

Pete
Shoot first and shoot people who ask questions, later.
Reply


Messages In This Thread
Another Mouse Issue? - by NakedApe - 04-25-2024, 12:54 AM
RE: Another Mouse Issue? - by SMcNeill - 04-25-2024, 01:06 AM
RE: Another Mouse Issue? - by TerryRitchie - 04-25-2024, 01:40 AM
RE: Another Mouse Issue? - by NakedApe - 05-01-2024, 11:42 PM
RE: Another Mouse Issue? - by SMcNeill - 05-02-2024, 12:23 AM
RE: Another Mouse Issue? - by Pete - 04-25-2024, 01:27 AM
RE: Another Mouse Issue? - by bplus - 04-25-2024, 01:42 AM
RE: Another Mouse Issue? - by TerryRitchie - 04-25-2024, 02:08 AM
RE: Another Mouse Issue? - by NakedApe - 04-25-2024, 02:16 AM
RE: Another Mouse Issue? - by TerryRitchie - 04-25-2024, 05:33 AM
RE: Another Mouse Issue? - by a740g - 04-26-2024, 02:23 AM
RE: Another Mouse Issue? - by bplus - 04-25-2024, 11:50 AM
RE: Another Mouse Issue? - by NakedApe - 04-25-2024, 04:11 PM
RE: Another Mouse Issue? - by TerryRitchie - 04-25-2024, 05:43 PM
RE: Another Mouse Issue? - by NakedApe - 04-26-2024, 06:19 AM
RE: Another Mouse Issue? - by TerryRitchie - 05-02-2024, 12:31 AM
RE: Another Mouse Issue? - by SMcNeill - 05-02-2024, 12:31 AM
RE: Another Mouse Issue? - by NakedApe - 05-02-2024, 03:16 AM



Users browsing this thread: 1 Guest(s)