MouseDown
This function is used to tell if a mouse button is pressed.
Syntax
- bool MouseDown(number button=1)
Parameters
- button: the mouse button to test. This can be one of the following values:
- 1: the left mouse button.
- 2: the right mouse button.
- 3: the middle mouse button (mouse wheel).
Returns
Returns true if the specified mouse button is pressed, otherwise false is returned.
Example
--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:Move(0,0,-3)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)
model = Model:Box()
model:SetColor(0.0,0.0,1.0)
while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end
Time:Update()
world:Update()
world:Render()
--press the left mouse button to see the result
context:SetBlendMode(Blend.Alpha)
context:DrawText("Mouse down: "..tostring(window:MouseDown(Key.LButton)),2,2);
context:Sync(false)
end