MouseButton
ButtonFlag = MouseButton()
 
Parameters: NONE
Returns:

    ButtonFlag = The Flags of what buttons are being pressed
 

      The MouseButton() function will return the current state of the three mouse buttons. It can not only return the state of the buttons separately, but combinations also.

[ Button States ]

      0= No buttons are pressed
      1= LEFT Mouse button is pressed
      2= RIGHT Mouse button is pressed
      3= Both the LEFT & RIGHT buttons are pressed
      4= MIDDLE/WHEEL button is pressed
      5= Both the LEFT & MIDDLE/WHEEL buttons are pressed
      6= Both the RIGHT & MIDDLE/WHEEL buttons are pressed
      7= All three buttons are being pressed.


      Those familiar with binary, you should be able to notice that each button state is represented as a separate bit. So you can mask the returned button state values to check the individual state of the buttons.


[ Button Bits ]

      Bit 0 = Left Mouse (Mask Value 1)
      Bit 1 = Right Mouse (Mask Value 2)
      Bit 2 = Middle Mouse (Mask Value 4)




FACTS:


      * If your not familiar with binary, or you just want to check the status of the LEFT or RIGHTt mouse buttons on their own, you should look into the LeftMouseButton(), RightMouseButton() and mind MidMouseButton() commands.




Mini Tutorial:


      This examble reads the current button state, then displays some messages about what combination of buttons are pressed.


  
; Start an infinite D0-LOOp
  Do
     
   ; Clear the screen to black RGB(0,0,0)
     Cls RGB(0,0,0)
     
   ; Read current Button status of the mouse.
     ButtonState = MouseButton()
     
   ; Display this button state to the screen.
     Print "Mouse Button State:"+Str$(ButtonState)
     
     
   ; Use a Select Statement to display a message of what
   ; mouse button combo is being pressed
     Select ButtonState
         Case 0
             Print "No Buttons are being pressed"
         Case 1
             Print "Left Mouse Button is pressed"
         Case 2
             Print "Right MOuse Button is pressed"
         Case 3
             Print "Both the LEFT & RIGHT buttons are pressed"
         Case 4
             Print "The Middle mouse button is pressed"
         Case 5
             Print "The LEFT and MIDDLE buttons are pressed"
         Case 6
             Print "The RIGHT and MIDDLE buttons are pressed"
         Case 7
             Print "All Three buttons are being pressed"
     EndSelect
     
   ; Mouse the Text Pen down to the Y position 100
     SetCursorY 100
     
     
   ; Now Check the BUTTONS using masking
     
   ; CHeck if the LEFT Button is pressed
     If (ButtonState And 1)<> 0
        Print "Left Button is down"
     EndIf
     
   ; Check if the RIGHT Button is pressed
     If (ButtonState And 2)<> 0
        Print "Right Button is down"
     EndIf
     
   ; Check if the MIDDLE Button is pressed
     If (ButtonState And 4)<> 0
        Print "Middle Button is down"
     EndIf
     
   ; Display the screen
     Sync
     
   ; Loop back to the DO statement
  Loop
  
  




 
Related Info: LeftMouseButton | MidMouseButton | MouseMoveX | MouseMoveY | MouseMoveZ | MouseX | MouseY | MouseZ | RightMouseButton :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com