Implements double click event on items, allowing to block the category expansion change.

This commit is contained in:
Leonardo Backes Vargas
2015-12-24 20:25:50 -02:00
parent 13669f7591
commit 3f1991ba1a
2 changed files with 52 additions and 17 deletions

View File

@@ -473,6 +473,18 @@ namespace nana
bool selected;
arg_listbox(const drawerbase::listbox::item_proxy&, bool selected);
};
struct arg_item
: public event_arg
{
drawerbase::listbox::index_pair item;
drawerbase::listbox::size_type column;
void block_category_change() const;
bool category_change_blocked() const;
arg_item(const drawerbase::listbox::index_pair&, drawerbase::listbox::size_type column);
private:
mutable bool _m_block_change;
};
namespace drawerbase
@@ -484,6 +496,7 @@ namespace nana
{
basic_event<arg_listbox> checked;
basic_event<arg_listbox> selected;
basic_event<arg_item> item_dbl_click;
};
struct scheme

View File

@@ -3545,7 +3545,7 @@ namespace nana
}
}
void trigger::dbl_click(graph_reference graph, const arg_mouse&)
void trigger::dbl_click(graph_reference graph, const arg_mouse& arg)
{
if (essence_->pointer_where.first == essence_t::parts::header)
if (cursor::size_we == essence_->lister.wd_ptr()->cursor())
@@ -3564,9 +3564,14 @@ namespace nana
//Get the item which the mouse is placed.
if (lister.forward(offset_y, essence_->pointer_where.second, item_pos))
{
drawerbase::listbox::size_type col=essence_->header.item_by_x(arg.pos.x - 2 - essence_->scroll.offset_x);
arg_item ai(item_pos, col==npos?-1:col);
lister.wd_ptr()->events().item_dbl_click.emit(ai);
if (!item_pos.is_category()) //being the npos of item.second is a category
return;
if(!ai.category_change_blocked()){
bool do_expand = (lister.expand(item_pos.cat) == false);
lister.expand(item_pos.cat, do_expand);
@@ -3582,6 +3587,7 @@ namespace nana
API::lazy_refresh();
}
}
}
void trigger::resized(graph_reference graph, const arg_resized&)
{
@@ -4285,6 +4291,22 @@ namespace nana
{
}
arg_item::arg_item ( const nana::drawerbase::listbox::index_pair& itm, nana::drawerbase::listbox::size_type column )
: item(itm), column(column), _m_block_change(false)
{
}
void arg_item::block_category_change() const {
_m_block_change=true;
}
bool arg_item::category_change_blocked() const {
return _m_block_change;
}
//class listbox
listbox::listbox(window wd, bool visible)
{