diff --git a/include/nana/gui/widgets/label.hpp b/include/nana/gui/widgets/label.hpp index ba6a5cf0..38f2dbc2 100644 --- a/include/nana/gui/widgets/label.hpp +++ b/include/nana/gui/widgets/label.hpp @@ -65,6 +65,8 @@ namespace nana label& format(bool); ///< Switches the format mode of the widget. label& add_format_listener(std::function); + void relate(widget& w); // as same as the "for" attribute of a label + /// \briefReturn the size of the text. If *allowed_width_in_pixel* is not zero, returns a /// "corrected" size that changes lines to fit the text into the specified width nana::size measure(unsigned allowed_width_in_pixel) const; diff --git a/source/gui/widgets/label.cpp b/source/gui/widgets/label.cpp index 66e76027..0784a36a 100644 --- a/source/gui/widgets/label.cpp +++ b/source/gui/widgets/label.cpp @@ -628,6 +628,8 @@ namespace nana nana::string target; //It indicates which target is tracing. nana::string url; + widget * buddy {nullptr}; + void add_listener(std::function&& fn) { listener_.emplace_back(std::move(fn)); @@ -740,6 +742,10 @@ namespace nana impl_->call_listener(command::click, impl_->target); system::open_url(url); + + if (impl_->buddy) { + impl_->buddy->focus(); + } } void trigger::refresh(graph_reference graph) @@ -821,6 +827,11 @@ namespace nana return *this; } + void label::relate(widget& w) + { + get_drawer_trigger().impl()->buddy = &w; + } + nana::size label::measure(unsigned limited) const { if(empty())