Intercettare il tasto premuto del mouse
Vai alla navigazione
Vai alla ricerca
Per sapere quale tasto del mouse è stato premuto, bisogna intercettare il numero identificativo ottenuto dallo stato del mouse.
Lo stato del mouse viene comunicato dalla proprietà Button di Mouse.
In particolare:
Mouse.Button.Left = 1
Mouse.Button.Middle = 4
Mouse.Button.Right = 2
Esempio:
Public Sub Form_MouseDown()
Select Case Mouse.Button
Case 1
Print "E' stato premuto il tasto \"Sinistro\" !"
Case 2
Print "E' stato premuto il tasto \"Destro\" !"
Case 4
Print "E' stato premuto il tasto \"Centrale\" (o la rotellina) !"
End Select
End
o, quindi, anche così:
Public Sub Form_MouseDown() With Mouse If .Left Then Print "Sinistro" If .Middle Then Print "Centrale" If .Right Then Print "Destro" End With End