For word Processing we need a mouse that can handle double and triple clicks, along with drag, right click, the mouse wheel, and we'll throw in middle clicks because I'm fresh out of kitchen sinks...
Code: (Select All)
Type mousevar
mx As Integer ' Row.
my As Integer ' Column.
wh As Integer ' Wheel.
lb_status As Integer ' Left Button Status.
rb_status As Integer ' Right Button Status.
mb_status As Integer ' Middle Button Status.
click As Integer ' Number of timed left button clicks.
CursorStyle As Integer ' 0 Default, 1 Link style. (Hand).
mousekey As String ' Auto Keyboard Input.
End Type
Dim m As mousevar
i = 3: j = 1: a$ = "None" ' Seed.
Do
_Limit 60
' Demo portion...
If j > 80 Then i = i + 1: j = 1: If i > 24 Then End
Select Case m.click
Case 1: a$ = "Single": If m.lb_status = 2 Then a$ = "Drag"
Case 2: a$ = "Double"
Case 3: a$ = "Triple"
End Select
Select Case m.wh
Case 0: b$ = "--"
Case 1: b$ = "Dn"
Case -1: b$ = "Up"
End Select
Locate 1, 3: Print "Row:"; m.my;: Locate 1, 11: Print "Col:"; m.mx;
Locate 1, 23: Print "Lt:"; m.lb_status; " Rt:"; m.rb_status; " Md:"; m.mb_status; " Whl: "; b$; " Last Left Click: "; a$; " ";
mouse m
Loop
Sub mouse (m As mousevar)
' Local vars: i%, j%, k%, button_active, button_status
Static As Integer oldmx, oldmy, button_active, last_active, button_status
Static As Long mtimer
If m.wh Then m.wh = 0
While _MouseInput
m.wh = m.wh + _MouseWheel
Wend
m.mx = _MouseX
m.my = _MouseY
i% = _MouseButton(1)
j% = _MouseButton(2)
k% = _MouseButton(3)
If i% And button_active = 0 Then
button_active = 1 ' Left button pressed.
ElseIf j% And button_active = 0 Then
button_active = 2 ' Right button pressed.
ElseIf k% And button_active = 0 Then
button_active = 3 ' Middle button pressed.
ElseIf button_active And i% + j% + k% = 0 Then
button_active = 0
End If
Select Case button_active
Case 0
Select Case button_status
Case -2
button_status = 0 ' The clicked event and the release triggered any event structured to occur on release.
Case -1
button_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
button_status = -1 ' Rare but button was released before the next required cycle, so cycle is continued here.
Case 2
button_status = -2 ' The drag event is over because the button was released.
End Select
Case Else
Select Case button_status ' Note drag is determined in the text highlighting routine.
Case -1
' An event occurred and the button is still down.
If button_active = 1 Then ' Only left button for drag events.
If oldmx <> m.mx Or oldmy <> m.my Then
button_status = 2 ' Drag.
End If
End If
Case 0
button_status = 1 ' Button just pressed.
If m.click = 0 And button_active = 1 Then
mtimer = Timer + .75
If mtimer > 86400 Then mtimer = mtimer - 86400 ' Midnight correction.
End If
m.click = Abs(m.click) + 1
Case 1
button_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
m.lb_status = 0: m.rb_status = 0: m.mb_status = 0
Select Case button_active
Case 0
Select Case last_active
Case 1: m.lb_status = button_status
Case 2: m.rb_status = button_status
Case 3: m.mb_status = button_status
End Select
Case 1 ' Left
m.lb_status = button_status
If Abs(m.click) And button_status < 1 Then m.click = -Abs(m.click) Else m.click = Abs(m.click)
Case 2 ' Right
m.rb_status = button_status
Case 3 ' Middle
m.mb_status = button_status
End Select
If Timer > mtimer Then m.click = 0
oldmx = m.mx: oldmy = m.my: last_active = button_active
End Sub