onFocusLost calls now focusHandler(false) when this handler is set

This commit is contained in:
Bertrand Songis
2020-04-28 10:09:38 +02:00
parent b166674604
commit dd9a87aa5f
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -121,7 +121,7 @@ void Window::setFocus(uint8_t flag)
clearFocus(); clearFocus();
focusWindow = this; focusWindow = this;
if (focusHandler) { if (focusHandler) {
focusHandler(); focusHandler(true);
} }
} }
+5 -2
View File
@@ -131,7 +131,7 @@ class Window {
closeHandler = std::move(handler); closeHandler = std::move(handler);
} }
void setFocusHandler(std::function<void()> handler) void setFocusHandler(std::function<void(bool)> handler)
{ {
focusHandler = std::move(handler); focusHandler = std::move(handler);
} }
@@ -360,7 +360,7 @@ class Window {
static std::list<Window *> trash; static std::list<Window *> trash;
std::function<void()> closeHandler; std::function<void()> closeHandler;
std::function<void()> focusHandler; std::function<void(bool)> focusHandler;
void addChild(Window * window, bool front = false) void addChild(Window * window, bool front = false)
{ {
@@ -389,6 +389,9 @@ class Window {
virtual void onFocusLost() virtual void onFocusLost()
{ {
TRACE_WINDOWS("%s onFocusLost()", getWindowDebugString().c_str()); TRACE_WINDOWS("%s onFocusLost()", getWindowDebugString().c_str());
if (focusHandler) {
focusHandler(false);
}
invalidate(); invalidate();
} }