File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1+ // Copyright (c) 2021 LibreSprite Authors (cf. AUTHORS.md)
2+ // This file is released under the terms of the MIT license.
3+ // Read LICENSE.txt for more information.
4+
5+ #include < gui/Controller.hpp>
6+ #include < gui/Events.hpp>
7+ #include < gui/Node.hpp>
8+
9+ class BlurRemove : public ui ::Controller {
10+ public:
11+ void attach () override {
12+ node ()->addEventListener <ui::Blur, ui::BlurChild>(this );
13+ }
14+
15+ void eventHandler (const ui::Blur&) {
16+ if (auto focus = node ()->getFocus (); !focus || !focus->isDescendantOf (node ()->shared_from_this ()))
17+ node ()->remove ();
18+ }
19+
20+ void eventHandler (const ui::BlurChild&) {
21+ if (auto focus = node ()->getFocus (); !focus || !focus->isDescendantOf (node ()->shared_from_this ()))
22+ node ()->remove ();
23+ }
24+ };
25+
26+ static ui::Controller::Shared<BlurRemove> blurremove{" blur-remove" };
Original file line number Diff line number Diff line change @@ -24,13 +24,16 @@ class DropDown : public ui::Controller {
2424 if (container)
2525 return container;
2626 container = ui::Node::fromXML (" dropdowncontainer" );
27+ container->load ({
28+ {" steal-focus" , true },
29+ {" controller" , " blur-remove" }
30+ });
2731
2832 for (auto & opt : getOptions ()) {
2933 auto entry = ui::Node::fromXML (" menubutton" );
3034 entry->load ({
3135 {" label" , opt},
3236 {" click" , FunctionRef<void ()>([=]{
33- logI (" Click " , opt);
3437 if (*value != opt) {
3538 container->remove ();
3639 node ()->load ({{" value" , opt}});
You can’t perform that action at this time.
0 commit comments