add treebox.horvered method

This commit is contained in:
Jinhao 2019-04-19 04:40:49 +08:00
parent 8b2dc1eddd
commit 5320ead6bd
2 changed files with 15 additions and 0 deletions

View File

@ -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<scroll_operation_interface> _m_scroll_operation() override;

View File

@ -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<drawer_trigger_t*>(dw), dw->impl()->node_state.pointed);
}
std::shared_ptr<scroll_operation_interface> treebox::_m_scroll_operation()
{
internal_scope_guard lock;