Fix UI click & focus
This commit is contained in:
parent
07f49d9e7e
commit
4222f4eb14
@ -172,7 +172,7 @@ void UIElement::hoverExitAll() {
|
|||||||
hoverExit();
|
hoverExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIElement::clickAll(UIPoint pos, UIPoint screenPos, GLFWMouseButton button) {
|
bool UIElement::clickAll(UIPoint pos, UIPoint screenPos, GLFWMouseButton button) {
|
||||||
UIElement *clickedChild = nullptr;
|
UIElement *clickedChild = nullptr;
|
||||||
for(UIElement *child : children) {
|
for(UIElement *child : children) {
|
||||||
UIPoint childPos = child->getPosition();
|
UIPoint childPos = child->getPosition();
|
||||||
@ -185,13 +185,18 @@ void UIElement::clickAll(UIPoint pos, UIPoint screenPos, GLFWMouseButton button)
|
|||||||
|
|
||||||
if(clickedChild != nullptr) {
|
if(clickedChild != nullptr) {
|
||||||
UIPoint childPos = clickedChild->getPosition();
|
UIPoint childPos = clickedChild->getPosition();
|
||||||
clickedChild->clickAll(UIPoint(pos.x - childPos.x, pos.y - childPos.y), screenPos, button);
|
if(clickedChild->clickAll(UIPoint(pos.x - childPos.x, pos.y - childPos.y), screenPos, button)) return true;
|
||||||
} else if(clickable) {
|
|
||||||
click(pos, screenPos, button);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIElement::focusEnterAll(UIPoint pos, UIPoint screenPos) {
|
if(clickable) {
|
||||||
|
click(pos, screenPos, button);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UIElement::focusEnterAll(UIPoint pos, UIPoint screenPos) {
|
||||||
UIElement *focusedChild = nullptr;
|
UIElement *focusedChild = nullptr;
|
||||||
for(UIElement *child : children) {
|
for(UIElement *child : children) {
|
||||||
UIPoint childPos = child->getPosition();
|
UIPoint childPos = child->getPosition();
|
||||||
@ -204,10 +209,15 @@ void UIElement::focusEnterAll(UIPoint pos, UIPoint screenPos) {
|
|||||||
|
|
||||||
if(focusedChild != nullptr) {
|
if(focusedChild != nullptr) {
|
||||||
UIPoint childPos = focusedChild->getPosition();
|
UIPoint childPos = focusedChild->getPosition();
|
||||||
focusedChild->focusEnterAll(UIPoint(pos.x - childPos.x, pos.y - childPos.y), screenPos);
|
if(focusedChild->focusEnterAll(UIPoint(pos.x - childPos.x, pos.y - childPos.y), screenPos)) return true;
|
||||||
} else if(focusable) {
|
|
||||||
UI::focusElement(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(focusable) {
|
||||||
|
UI::focusElement(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UIElement *UIElement::dragEnterAll(UIPoint pos, UIPoint screenPos) {
|
UIElement *UIElement::dragEnterAll(UIPoint pos, UIPoint screenPos) {
|
||||||
|
@ -181,10 +181,10 @@ class UIElement {
|
|||||||
virtual void hover(UIPoint pos, UIPoint screenPos){};
|
virtual void hover(UIPoint pos, UIPoint screenPos){};
|
||||||
virtual void hoverExit(){};
|
virtual void hoverExit(){};
|
||||||
|
|
||||||
void clickAll(UIPoint pos, UIPoint screenPos, GLFWMouseButton button);
|
bool clickAll(UIPoint pos, UIPoint screenPos, GLFWMouseButton button);
|
||||||
virtual void click(UIPoint pos, UIPoint screenPos, GLFWMouseButton button){};
|
virtual void click(UIPoint pos, UIPoint screenPos, GLFWMouseButton button){};
|
||||||
|
|
||||||
void focusEnterAll(UIPoint pos, UIPoint screenPos);
|
bool focusEnterAll(UIPoint pos, UIPoint screenPos);
|
||||||
virtual void focusEnter(){};
|
virtual void focusEnter(){};
|
||||||
virtual void focusExit(){};
|
virtual void focusExit(){};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user