From 3b80386cf89118c401ba83986088d98e4b5e67fc Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 31 Aug 2019 15:43:57 +0200 Subject: [PATCH] fix popup menu on_select event --- src/node_panel_brush.cpp | 2 +- src/node_popup_menu.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/node_panel_brush.cpp b/src/node_panel_brush.cpp index 26eace9..aa592b1 100644 --- a/src/node_panel_brush.cpp +++ b/src/node_panel_brush.cpp @@ -469,7 +469,7 @@ void NodePanelBrushPreset::init() case 0: // download break; case 1: // import - App::I->pick_file({".abr", ".ABR"}, [] (std::string path) { + App::I->pick_file({"abr", "ppbr"}, [] (std::string path) { std::thread([path] { BT_SetTerminate(); App::I->stroke->import_abr(path); diff --git a/src/node_popup_menu.cpp b/src/node_popup_menu.cpp index 3b361c3..141276d 100644 --- a/src/node_popup_menu.cpp +++ b/src/node_popup_menu.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "log.h" #include "node_popup_menu.h" +#include "node_button_custom.h" Node* NodePopupMenu::clone_instantiate() const { @@ -9,11 +10,11 @@ Node* NodePopupMenu::clone_instantiate() const void NodePopupMenu::init() { - m_flood_events = true; SetPosition(0, 0); SetWidth(100); SetHeight(500); SetPositioning(YGPositionTypeAbsolute); + m_flood_events = true; m_mouse_ignore = false; m_capture_children = false; } @@ -57,4 +58,14 @@ void NodePopupMenu::added(Node* parent) m_mouse_ignore = false; m_flood_events = true; m_capture_children = false; + for (int i = 0; i < m_children.size(); i++) + { + if (auto b = std::dynamic_pointer_cast(m_children[i])) + { + b->on_click = [this, i](Node* target) { + if (on_select) + on_select(this, i); + }; + } + } }