add 'onrightclick' uinode event
This commit is contained in:
parent
645f150ff2
commit
1fd81da82e
@ -177,6 +177,7 @@ void Container::add(const std::shared_ptr<UINode>& node) {
|
|||||||
parent->setMustRefresh();
|
parent->setMustRefresh();
|
||||||
parent = parent->getParent();
|
parent = parent->getParent();
|
||||||
}
|
}
|
||||||
|
gui.getWindow().setShouldRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::add(const std::shared_ptr<UINode>& node, glm::vec2 pos) {
|
void Container::add(const std::shared_ptr<UINode>& node, glm::vec2 pos) {
|
||||||
|
|||||||
@ -69,6 +69,11 @@ UINode* UINode::listenAction(const onaction& action) {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UINode* UINode::listenRightClick(const onaction& action) {
|
||||||
|
rightClickCallbacks.listen(action);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
UINode* UINode::listenDoubleClick(const onaction& action) {
|
UINode* UINode::listenDoubleClick(const onaction& action) {
|
||||||
doubleClickCallbacks.listen(action);
|
doubleClickCallbacks.listen(action);
|
||||||
return this;
|
return this;
|
||||||
@ -88,6 +93,12 @@ void UINode::click(int, int) {
|
|||||||
pressed = true;
|
pressed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UINode::clicked(Mousecode button) {
|
||||||
|
if (button == Mousecode::BUTTON_2) {
|
||||||
|
rightClickCallbacks.notify(gui);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UINode::doubleClick(int x, int y) {
|
void UINode::doubleClick(int x, int y) {
|
||||||
pressed = true;
|
pressed = true;
|
||||||
if (isInside(glm::vec2(x, y))) {
|
if (isInside(glm::vec2(x, y))) {
|
||||||
|
|||||||
@ -121,6 +121,8 @@ namespace gui {
|
|||||||
vec2supplier sizefunc = nullptr;
|
vec2supplier sizefunc = nullptr;
|
||||||
/// @brief 'onclick' callbacks
|
/// @brief 'onclick' callbacks
|
||||||
ActionsSet actions;
|
ActionsSet actions;
|
||||||
|
/// @brief 'onrightclick' callbacks
|
||||||
|
ActionsSet rightClickCallbacks;
|
||||||
/// @brief 'ondoubleclick' callbacks
|
/// @brief 'ondoubleclick' callbacks
|
||||||
ActionsSet doubleClickCallbacks;
|
ActionsSet doubleClickCallbacks;
|
||||||
/// @brief 'onfocus' callbacks
|
/// @brief 'onfocus' callbacks
|
||||||
@ -188,6 +190,7 @@ namespace gui {
|
|||||||
int getZIndex() const;
|
int getZIndex() const;
|
||||||
|
|
||||||
virtual UINode* listenAction(const onaction& action);
|
virtual UINode* listenAction(const onaction& action);
|
||||||
|
virtual UINode* listenRightClick(const onaction& action);
|
||||||
virtual UINode* listenDoubleClick(const onaction& action);
|
virtual UINode* listenDoubleClick(const onaction& action);
|
||||||
virtual UINode* listenFocus(const onaction& action);
|
virtual UINode* listenFocus(const onaction& action);
|
||||||
virtual UINode* listenDefocus(const onaction& action);
|
virtual UINode* listenDefocus(const onaction& action);
|
||||||
@ -195,7 +198,7 @@ namespace gui {
|
|||||||
virtual void onFocus();
|
virtual void onFocus();
|
||||||
virtual void doubleClick(int x, int y);
|
virtual void doubleClick(int x, int y);
|
||||||
virtual void click(int x, int y);
|
virtual void click(int x, int y);
|
||||||
virtual void clicked(Mousecode button) {}
|
virtual void clicked(Mousecode button);
|
||||||
virtual void mouseMove(int x, int y) {};
|
virtual void mouseMove(int x, int y) {};
|
||||||
virtual void mouseRelease(int x, int y);
|
virtual void mouseRelease(int x, int y);
|
||||||
virtual void scrolled(int value);
|
virtual void scrolled(int value);
|
||||||
|
|||||||
@ -181,6 +181,10 @@ static void read_uinode(
|
|||||||
node.listenAction(onclick);
|
node.listenAction(onclick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto onclick = create_action(reader, element, "onrightclick")) {
|
||||||
|
node.listenRightClick(onclick);
|
||||||
|
}
|
||||||
|
|
||||||
if (auto onfocus = create_action(reader, element, "onfocus")) {
|
if (auto onfocus = create_action(reader, element, "onfocus")) {
|
||||||
node.listenFocus(onfocus);
|
node.listenFocus(onfocus);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user