add app.focus function

This commit is contained in:
MihailRis 2025-11-15 21:22:18 +03:00
parent 6195d014cd
commit c42d661223
3 changed files with 13 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include "engine/EnginePaths.hpp"
#include "network/Network.hpp"
#include "util/platform.hpp"
#include "window/Window.hpp"
using namespace scripting;
@ -27,8 +28,14 @@ static int l_start_debug_instance(lua::State* L) {
return lua::pushinteger(L, port);
}
static int l_focus(lua::State* L) {
engine->getWindow().focus();
return 0;
}
const luaL_Reg applib[] = {
{"start_debug_instance", lua::wrap<l_start_debug_instance>},
{"focus", lua::wrap<l_focus>},
// for other functions see libcore.cpp and stdlib.lua
{nullptr, nullptr}
};

View File

@ -36,6 +36,8 @@ public:
virtual void setMode(WindowMode mode) = 0;
virtual WindowMode getMode() const = 0;
virtual void focus() = 0;
virtual void setTitle(const std::string& title) = 0;
virtual void setIcon(const ImageData* image) = 0;

View File

@ -468,6 +468,10 @@ public:
return mode;
}
void focus() override {
glfwFocusWindow(window);
}
void setTitle(const std::string& title) override {
glfwSetWindowTitle(window, title.c_str());
}