Differenze tra le versioni di "Intercettare il tasto premuto del mouse"

Da Gambas-it.org - Wikipedia.
(Nuova pagina: Per sapere quale tasto del mouse è stato premuto, bisogna intercettare il numero identificativo ottenuto dallo ''stato'' del mouse. <BR>Lo ''stato'' del mouse viene comunicato dalla p...)
 
Riga 18: Riga 18:
 
         Print "E' stato premuto il tasto \"Centrale\" (o la rotellina) !"
 
         Print "E' stato premuto il tasto \"Centrale\" (o la rotellina) !"
 
     End Select
 
     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'''
 
  '''End'''

Versione delle 20:48, 22 ago 2012

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