mirror of
https://github.com/love2d/love.git
synced 2026-08-21 13:09:56 +02:00
Added love.focus callback
This commit is contained in:
@@ -8,6 +8,7 @@ LOVE 0.7.0
|
||||
* Added Font:getWrap.
|
||||
* Added identity field to love.conf.
|
||||
* Added love.quit callback.
|
||||
* Added love.focus callback.
|
||||
* Added extra meter parameter to love.physics.newWorld.
|
||||
* Added love.graphics.setIcon.
|
||||
* Enabled love.filesystem.FileData.
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace event
|
||||
{"mr", Event::TYPE_MOUSE_RELEASED},
|
||||
{"jp", Event::TYPE_JOYSTICK_PRESSED},
|
||||
{"jr", Event::TYPE_JOYSTICK_RELEASED},
|
||||
{"f", Event::TYPE_FOCUS},
|
||||
{"q", Event::TYPE_QUIT},
|
||||
};
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace event
|
||||
TYPE_MOUSE_RELEASED,
|
||||
TYPE_JOYSTICK_RELEASED,
|
||||
TYPE_JOYSTICK_PRESSED,
|
||||
TYPE_FOCUS,
|
||||
TYPE_QUIT,
|
||||
TYPE_MAX_ENUM = 32
|
||||
};
|
||||
@@ -73,6 +74,12 @@ namespace event
|
||||
love::keyboard::Keyboard::Key k;
|
||||
unsigned short u;
|
||||
} keyboard;
|
||||
|
||||
struct
|
||||
{
|
||||
Type type;
|
||||
bool f;
|
||||
} focus;
|
||||
};
|
||||
|
||||
virtual ~Event();
|
||||
|
||||
@@ -96,6 +96,12 @@ namespace sdl
|
||||
m.joystick.button = e.jbutton.button;
|
||||
m.joystick.index = e.jbutton.which;
|
||||
return true;
|
||||
case SDL_ACTIVEEVENT:
|
||||
if (e.active.state & SDL_APPINPUTFOCUS) {
|
||||
m.type = Event::TYPE_FOCUS;
|
||||
m.focus.f = e.active.gain;
|
||||
return true;
|
||||
} else break;
|
||||
case SDL_QUIT:
|
||||
m.type = Event::TYPE_QUIT;
|
||||
return true;
|
||||
@@ -127,6 +133,10 @@ namespace sdl
|
||||
e.jbutton.which = m.joystick.index;
|
||||
e.jbutton.button = m.joystick.button;
|
||||
return true;
|
||||
case Event::TYPE_FOCUS:
|
||||
e.type = SDL_ACTIVEEVENT;
|
||||
e.active.state = SDL_APPINPUTFOCUS;
|
||||
e.active.gain = m.focus.f;
|
||||
case Event::TYPE_QUIT:
|
||||
e.type = SDL_QUIT;
|
||||
return true;
|
||||
|
||||
@@ -64,6 +64,9 @@ namespace sdl
|
||||
msg.joystick.index = luaL_checkint(L, 2);
|
||||
msg.joystick.button = luaL_checkint(L, 3);
|
||||
return true;
|
||||
case Event::TYPE_FOCUS:
|
||||
msg.focus.f = lua_toboolean(L, 2);
|
||||
return true;
|
||||
case Event::TYPE_QUIT:
|
||||
return true;
|
||||
default:
|
||||
@@ -108,6 +111,9 @@ namespace sdl
|
||||
lua_pushinteger(L, msg.joystick.index);
|
||||
lua_pushinteger(L, msg.joystick.button);
|
||||
return 3;
|
||||
case Event::TYPE_FOCUS:
|
||||
lua_pushboolean(L, msg.focus.f);
|
||||
return 2;
|
||||
case Event::TYPE_QUIT:
|
||||
return 1;
|
||||
default:
|
||||
|
||||
@@ -170,6 +170,9 @@ function love.createhandlers()
|
||||
jr = function (j,b)
|
||||
if love.joystickreleased then love.joystickreleased(j,b) end
|
||||
end,
|
||||
f = function (f)
|
||||
if love.focus then love.focus(f) end
|
||||
end,
|
||||
q = function ()
|
||||
return
|
||||
end,
|
||||
|
||||
+947
-942
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user