From 5320ead6bd4338c5f15a98a445c7426ac9e2d2f2 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 19 Apr 2019 04:40:49 +0800 Subject: [PATCH] add treebox.horvered method --- include/nana/gui/widgets/treebox.hpp | 2 ++ source/gui/widgets/treebox.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/nana/gui/widgets/treebox.hpp b/include/nana/gui/widgets/treebox.hpp index ba40c4c1..9c865076 100644 --- a/include/nana/gui/widgets/treebox.hpp +++ b/include/nana/gui/widgets/treebox.hpp @@ -480,6 +480,8 @@ namespace nana */ void scroll_into_view(item_proxy item); + /// Gets the current hovered node. + item_proxy hovered(bool exclude_expander) const; private: std::shared_ptr _m_scroll_operation() override; diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index eb859353..5b6e3c0d 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -2371,6 +2371,19 @@ namespace nana API::refresh_window(*this); } + treebox::item_proxy treebox::hovered(bool exclude_expander) const + { + internal_scope_guard lock; + auto dw = &get_drawer_trigger(); + if (dw->impl()->node_state.pointed) + { + //Returns empty item_proxy if the mouse is on expander and exclude_expander is required. + if (exclude_expander && (dw->impl()->node_state.comp_pointed == drawerbase::treebox::component::expander)) + return item_proxy{}; + } + return item_proxy(const_cast(dw), dw->impl()->node_state.pointed); + } + std::shared_ptr treebox::_m_scroll_operation() { internal_scope_guard lock;