fix mouse left button issues due to breaking changes

This commit is contained in:
Jinhao
2015-07-28 00:00:15 +08:00
parent 5dd5d110d7
commit 396163c1b7
13 changed files with 93 additions and 72 deletions

View File

@@ -622,7 +622,7 @@ namespace nana
if(drawer_->widget_ptr()->enabled())
{
auto * editor = drawer_->editor();
if(false == editor->mouse_down(arg.left_button, arg.pos))
if(false == editor->mouse_down(arg.button, arg.pos))
drawer_->open_lister_if_push_button_positioned();
drawer_->draw();
@@ -637,7 +637,7 @@ namespace nana
{
if (drawer_->widget_ptr()->enabled() && !drawer_->has_lister())
{
drawer_->editor()->mouse_up(arg.left_button, arg.pos);
drawer_->editor()->mouse_up(arg.button, arg.pos);
drawer_->set_button_state(element_state::hovered, false);
drawer_->draw();
API::lazy_refresh();

View File

@@ -34,7 +34,7 @@ namespace nana
{
if (state == StateHighlighted)
{
::nana::color clr{ 0xaf, 0xc7, 0xe3 };
::nana::color clr(static_cast<color_rgb>(0xafc7e3));
graph.rectangle(r, false, clr);
auto right = r.right() - 1;
@@ -276,7 +276,7 @@ namespace nana
}
}
bool right_area(graph_reference graph, int x, int y) const
static bool right_area(graph_reference graph, int x, int y)
{
return ((1 < x && 1 < y) &&
x < static_cast<int>(graph.width()) - 2 &&
@@ -325,7 +325,7 @@ namespace nana
_m_open_scrollbar(*widget_, pages);
}
else
graph_->string({ 4, 4 }, STR("Empty Listbox, No Module!"), {0x80, 0x80, 0x80});
graph_->string({ 4, 4 }, STR("Empty Listbox, No Module!"), static_cast<color_rgb>(0x808080));
//Draw border
graph_->rectangle(false, colors::black);
@@ -361,7 +361,7 @@ namespace nana
auto fn = [this](const arg_mouse& arg)
{
if (arg.left_button && (scrollbar_.value() != state_.offset_y))
if (arg.is_left_button() && (scrollbar_.value() != state_.offset_y))
{
state_.offset_y = static_cast<unsigned>(scrollbar_.value());
draw();
@@ -449,12 +449,16 @@ namespace nana
void trigger::mouse_up(graph_reference graph, const arg_mouse& arg)
{
if(drawer_->right_area(graph, arg.pos.x, arg.pos.y))
bool close_wdg = false;
if (drawer_->right_area(graph, arg.pos.x, arg.pos.y))
{
drawer_->set_result();
drawer_->widget_ptr()->close();
close_wdg = true;
}
else if(false == drawer_->ignore_emitting_mouseup())
else
close_wdg = (false == drawer_->ignore_emitting_mouseup());
if (close_wdg)
drawer_->widget_ptr()->close();
}
//end class trigger

View File

@@ -754,23 +754,26 @@ namespace nana
API::register_menu_window(this->handle(), !owner_menubar);
}
events().destroy.connect_unignorable([this]{
auto & events = this->events();
events.destroy.connect_unignorable([this]{
_m_destroy();
});
events().key_press.connect_unignorable([this](const arg_keyboard& arg){
events.key_press.connect_unignorable([this](const arg_keyboard& arg){
_m_key_down(arg);
});
events().mouse_down.connect_unignorable([this](const arg_mouse& arg)
auto fn = [this](const arg_mouse& arg)
{
this->_m_open_sub(0); //Try to open submenu immediately
});
if (event_code::mouse_down == arg.evt_code)
_m_open_sub(0); //Try to open submenu immediately
else if (event_code::mouse_up == arg.evt_code)
if (arg.button == ::nana::mouse::left_button)
pick();
};
events().mouse_up.connect_unignorable([this](const arg_mouse& arg){
if (arg.left_button)
pick();
});
events.mouse_down.connect_unignorable(fn);
events.mouse_up.connect_unignorable(fn);
timer_.interval(100);
timer_.elapse([this]{
@@ -782,7 +785,7 @@ namespace nana
if (want_focus_)
{
event_focus_ = events().focus.connect_unignorable([this](const arg_focus& arg)
event_focus_ = events.focus.connect_unignorable([this](const arg_focus& arg)
{
//when the focus of the menu window is losing, close the menu.
//But here is not every menu window may have focus event installed,

View File

@@ -1593,12 +1593,12 @@ namespace nana{ namespace widgets
return true;
}
bool text_editor::mouse_down(bool left_button, const point& scrpos)
bool text_editor::mouse_down(::nana::mouse button, const point& scrpos)
{
if (!hit_text_area(scrpos))
return false;
if(left_button)
if(::nana::mouse::left_button == button)
{
API::capture_window(window_, true);
text_area_.captured = true;
@@ -1646,7 +1646,7 @@ namespace nana{ namespace widgets
return false;
}
bool text_editor::mouse_up(bool left_button, const point& scrpos)
bool text_editor::mouse_up(::nana::mouse button, const point& scrpos)
{
auto is_prev_no_selected = (select_.mode_selection == selection::mode_no_selected);

View File

@@ -371,9 +371,9 @@ namespace nana
bool refreshed = false;
if (pressed)
refreshed = editor_->mouse_down(arg.left_button, arg.pos);
refreshed = editor_->mouse_down(arg.button, arg.pos);
else
refreshed = editor_->mouse_up(arg.left_button, arg.pos);
refreshed = editor_->mouse_up(arg.button, arg.pos);
if (refreshed)
_m_draw_spins(buttons::none);

View File

@@ -97,7 +97,7 @@ namespace drawerbase {
void drawer::mouse_down(graph_reference, const arg_mouse& arg)
{
if(editor_->mouse_down(arg.left_button, arg.pos))
if(editor_->mouse_down(arg.button, arg.pos))
API::lazy_refresh();
}
@@ -109,7 +109,7 @@ namespace drawerbase {
void drawer::mouse_up(graph_reference graph, const arg_mouse& arg)
{
if(editor_->mouse_up(arg.left_button, arg.pos))
if(editor_->mouse_up(arg.button, arg.pos))
API::lazy_refresh();
}

View File

@@ -277,7 +277,7 @@ namespace nana
impl_->which = which;
if (which == npos || container.at(which)->enable)
{
impl_->state = (arg.left_button ? item_renderer::state_t::selected : item_renderer::state_t::highlighted);
impl_->state = item_renderer::state_t::highlighted;
refresh(graph);
API::lazy_refresh();

View File

@@ -583,7 +583,7 @@ namespace nana
void event_scrollbar(const arg_mouse& arg)
{
if((event_code::mouse_wheel == arg.evt_code) || arg.left_button)
if((event_code::mouse_wheel == arg.evt_code) || arg.is_left_button())
{
if(shape.prev_first_value != shape.scroll.value())
{
@@ -719,17 +719,29 @@ namespace nana
node_state.tooltip->impl().assign(node_attr, &data.renderer, &data.comp_placer);
node_state.tooltip->show();
auto & events = node_state.tooltip->events();
events.mouse_leave.connect([this](const arg_mouse&){
this->close_tooltip_window();
});
events.mouse_move.connect([this](const arg_mouse&){
this->mouse_move_tooltip_window();
});
auto fn = [this](const arg_mouse& arg){
this->click_tooltip_window(arg);
auto fn = [this](const arg_mouse& arg)
{
switch (arg.evt_code)
{
case event_code::mouse_leave:
close_tooltip_window();
break;
case event_code::mouse_move:
mouse_move_tooltip_window();
break;
case event_code::mouse_down:
case event_code::mouse_up:
case event_code::dbl_click:
click_tooltip_window(arg);
break;
default: //ignore other events
break;
}
};
auto & events = node_state.tooltip->events();
events.mouse_leave(fn);
events.mouse_move(fn);
events.mouse_down.connect(fn);
events.mouse_up.connect(fn);
events.dbl_click.connect(fn);