Skip to content

MouseHit

Narta Xaymar Dirks edited this page Nov 25, 2026 · 12 revisions

MouseHit BlitzBasic

MouseHit:Int32 button:Int32, device:Int32=-1
Parameter Mode Type Default Description
button In Int32 required 1 for the left, 2 for the right, 3 for the middle button, 4 for the back (X1) and 5 for the forward (X2) button.
device In Int32 -1 Only look at this mouse, counted from 0 as in MouseDeviceCount. -1 (the default) means all mice together.

Returns: How many times the button was pressed since the last call.

Description

Counts presses of a mouse button since the last time MouseHit asked about that button. Use it for clicks that should do one thing and not repeat while the button is held, and MouseDown for dragging.

Differences

  • Buttons 4 and 5 (the back and forward buttons) are a BlitzLLVM extension. A button number outside 1 to 5 always gives 0.
  • The Device argument is a BlitzLLVM extension: the original has no such argument and only knows one mouse.

Examples

Graphics 320, 240, 0, 2
SetBuffer BackBuffer()
Local clicks = 0
While Not KeyHit(1)
	If MouseHit(1) Then clicks = clicks + 1
	Cls
	Text 10, 10, "Left clicks: " + clicks
	Flip
Wend

Related Commands

MouseChanged BlitzLLVM, MouseDeviceConnected BlitzLLVM, MouseDeviceCount BlitzLLVM, MouseDeviceName BlitzLLVM, MouseDown BlitzBasic, MouseWait BlitzBasic, MouseX BlitzBasic, MouseXSpeed BlitzBasic

Home · Command Index


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

More

Clone this wiki locally