Implement window close button
This commit is contained in:
parent
9b9f7a286a
commit
39775453f2
@ -66,13 +66,14 @@ static void doUIMouseClick(double x, double y, GLFWMouseButton button) {
|
|||||||
if(clickedElement) {
|
if(clickedElement) {
|
||||||
UIPoint childPos = clickedElement->getPosition();
|
UIPoint childPos = clickedElement->getPosition();
|
||||||
UIPoint clickedAt = UIPoint((int) x - childPos.x, (int) y - childPos.y);
|
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(button == GLFWMouseButton::LEFT) {
|
||||||
if(!clickedElement->focusEnterAll(clickedAt, UIPoint((int) x, (int) y))) {
|
if(!clickedElement->focusEnterAll(clickedAt, UIPoint((int) x, (int) y))) {
|
||||||
UI::unfocusElement(kekData.ui->focusedElement);
|
UI::unfocusElement(kekData.ui->focusedElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clickedElement->clickAll(clickedAt, UIPoint((int) x, (int) y), button);
|
||||||
} else {
|
} else {
|
||||||
UI::unfocusElement(kekData.ui->focusedElement);
|
UI::unfocusElement(kekData.ui->focusedElement);
|
||||||
}
|
}
|
||||||
|
@ -372,6 +372,11 @@ UIWindow::UIWindow(UIValue x, UIValue y, UIValue w, UIValue h)
|
|||||||
|
|
||||||
this->titleBar = new UIWindowTitleBar(uiPx(25));
|
this->titleBar = new UIWindowTitleBar(uiPx(25));
|
||||||
addChild(titleBar);
|
addChild(titleBar);
|
||||||
|
|
||||||
|
titleBar->closeButton->onClick = Callable([](void *element) {
|
||||||
|
UI::removeElement((UIElement *) element);
|
||||||
|
},
|
||||||
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
UIWindow::~UIWindow() {
|
UIWindow::~UIWindow() {
|
||||||
|
Loading…
Reference in New Issue
Block a user