add 'onfocus' ui event & optimize container:add

This commit is contained in:
MihailRis
2025-04-26 20:16:57 +03:00
parent 8e8cabf2d1
commit 1e90115a26
9 changed files with 31 additions and 10 deletions
+10
View File
@@ -74,6 +74,11 @@ UINode* UINode::listenDoubleClick(const onaction& action) {
return this;
}
UINode* UINode::listenFocus(const onaction& action) {
focusCallbacks.listen(action);
return this;
}
UINode* UINode::listenDefocus(const onaction& action) {
defocusCallbacks.listen(action);
return this;
@@ -101,6 +106,11 @@ bool UINode::isPressed() const {
return pressed;
}
void UINode::onFocus() {
focused = true;
focusCallbacks.notify(gui);
}
void UINode::defocus() {
focused = false;
defocusCallbacks.notify(gui);