Difference between revisions of "love.focus"

m
(Example)
Line 22: Line 22:
  
 
function love.focus(f)
 
function love.focus(f)
   if not f then
+
   if f then
    text = "UNFOCUSED!!"
+
     print("Window is focused.")
     print("LOST FOCUS")
 
 
   else
 
   else
    text = "FOCUSED!"
+
     print("Window is not focused.")
     print("GAINED FOCUS")
 
 
   end
 
   end
 
end
 
end
  
 
</source>
 
</source>
 +
 
== See Also ==
 
== See Also ==
 
* [[parent::love]]
 
* [[parent::love]]

Revision as of 10:10, 1 July 2015

Available since LÖVE 0.7.0
This callback is not supported in earlier versions.

Callback function triggered when window receives or loses focus.

Function

Synopsis

love.focus( f )

Arguments

boolean f
Window focus

Returns

Nothing.

Example

function love.load()
  text = "FOCUSED"
end

function love.draw()
  love.graphics.print(text,0,0)
end

function love.focus(f)
  if f then
    print("Window is focused.")
  else
    print("Window is not focused.")
  end
end

See Also


Other Languages