Difference between revisions of "love.mouse.setGrab"

(Add an example, see also)
m (typo)
Line 21: Line 21:
 
== See Also ==
 
== See Also ==
 
* [[parent::love.mouse]]
 
* [[parent::love.mouse]]
[[love.mouse.isGrabbed]]
+
* [[love.mouse.isGrabbed]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Grabs the mouse and confines it to the window.}}
 
{{#set:Description=Grabs the mouse and confines it to the window.}}

Revision as of 16:11, 27 September 2011

Grabs the mouse and confines it to the window.

Function

Synopsis

love.mouse.setGrab( grab )

Arguments

boolean grab
True to confine the mouse, false to let it leave the window.

Returns

Nothing.

Examples

Toggles whether the mouse is grabbed by pressing tab, with the help of love.mouse.isGrabbed.

function love.keypressed(key)
   if key == "tab" then
      local state = not love.mouse.isGrabbed()   -- the opposite of whatever it currently is
      love.mouse.setGrab(state)
   end
end

See Also


Other Languages