Implement window close button

This commit is contained in:
MrLetsplay 2024-01-29 22:42:11 +01:00
parent 9b9f7a286a
commit 39775453f2
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
2 changed files with 7 additions and 1 deletions

View File

@ -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);
}

View File

@ -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() {