mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Added love.window.hasMouseFocus (issue #120)
This commit is contained in:
@@ -76,6 +76,8 @@ public:
|
||||
virtual void swapBuffers();
|
||||
|
||||
virtual bool hasFocus() const = 0;
|
||||
virtual bool hasMouseFocus() const = 0;
|
||||
|
||||
virtual void setMouseVisible(bool visible) = 0;
|
||||
virtual bool getMouseVisible() const = 0;
|
||||
|
||||
|
||||
@@ -305,6 +305,11 @@ bool Window::hasFocus() const
|
||||
return (SDL_GetAppState() & SDL_APPINPUTFOCUS) != 0;
|
||||
}
|
||||
|
||||
bool Window::hasMouseFocus() const
|
||||
{
|
||||
return (SDL_GetAppState() & SDL_APPMOUSEFOCUS) != 0;
|
||||
}
|
||||
|
||||
void Window::setMouseVisible(bool visible)
|
||||
{
|
||||
SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE);
|
||||
|
||||
@@ -57,6 +57,8 @@ public:
|
||||
void swapBuffers();
|
||||
|
||||
bool hasFocus() const;
|
||||
bool hasMouseFocus() const;
|
||||
|
||||
void setMouseVisible(bool visible);
|
||||
bool getMouseVisible() const;
|
||||
|
||||
|
||||
@@ -208,6 +208,12 @@ int w_hasFocus(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_hasMouseFocus(lua_State *L)
|
||||
{
|
||||
luax_pushboolean(L, instance->hasMouseFocus());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] =
|
||||
{
|
||||
{ "checkMode", w_checkMode },
|
||||
@@ -223,6 +229,7 @@ static const luaL_Reg functions[] =
|
||||
{ "setTitle", w_setTitle },
|
||||
{ "getTitle", w_getTitle },
|
||||
{ "hasFocus", w_hasFocus },
|
||||
{ "hasMouseFocus", w_hasMouseFocus },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ int w_setIcon(lua_State *L);
|
||||
int w_setTitle(lua_State *L);
|
||||
int w_getTitle(lua_State *L);
|
||||
int w_hasFocus(lua_State *L);
|
||||
int w_hasMouseFocus(lua_State *L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_window(lua_State *L);
|
||||
|
||||
} // window
|
||||
|
||||
Reference in New Issue
Block a user