diff --git a/src/kekengine/cpp/common/defaults.cpp b/src/kekengine/cpp/common/defaults.cpp index e4cef71..ad8292f 100644 --- a/src/kekengine/cpp/common/defaults.cpp +++ b/src/kekengine/cpp/common/defaults.cpp @@ -66,13 +66,14 @@ static void doUIMouseClick(double x, double y, GLFWMouseButton button) { if(clickedElement) { UIPoint childPos = clickedElement->getPosition(); UIPoint clickedAt = UIPoint((int) x - childPos.x, (int) y - childPos.y); - clickedElement->clickAll(clickedAt, UIPoint((int) x, (int) y), button); if(button == GLFWMouseButton::LEFT) { if(!clickedElement->focusEnterAll(clickedAt, UIPoint((int) x, (int) y))) { UI::unfocusElement(kekData.ui->focusedElement); } } + + clickedElement->clickAll(clickedAt, UIPoint((int) x, (int) y), button); } else { UI::unfocusElement(kekData.ui->focusedElement); } diff --git a/src/kekengine/cpp/ui/uielements.cpp b/src/kekengine/cpp/ui/uielements.cpp index 3e518e7..df06f92 100644 --- a/src/kekengine/cpp/ui/uielements.cpp +++ b/src/kekengine/cpp/ui/uielements.cpp @@ -372,6 +372,11 @@ UIWindow::UIWindow(UIValue x, UIValue y, UIValue w, UIValue h) this->titleBar = new UIWindowTitleBar(uiPx(25)); addChild(titleBar); + + titleBar->closeButton->onClick = Callable([](void *element) { + UI::removeElement((UIElement *) element); + }, + this); } UIWindow::~UIWindow() {