change parameter type of click event from arg_mouse to arg_click

This commit is contained in:
Jinhao
2015-07-21 01:14:23 +08:00
parent d8a964d8f0
commit 5bc1568f3e
13 changed files with 214 additions and 151 deletions

View File

@@ -195,6 +195,16 @@ namespace nana
switch (evt_code)
{
case event_code::click:
{
auto arg = dynamic_cast<const arg_click*>(&event_arg);
if (nullptr == arg)
return;
wd->drawer.click(*arg);
if (!draw_only)
evts_ptr->click.emit(*arg);
}
break;
case event_code::dbl_click:
case event_code::mouse_enter:
case event_code::mouse_move:
@@ -211,10 +221,6 @@ namespace nana
switch (evt_code)
{
case event_code::click:
drawer_event_fn = &drawer::click;
evt_addr = &evts_ptr->click;
break;
case event_code::dbl_click:
drawer_event_fn = &drawer::dbl_click;
evt_addr = &evts_ptr->dbl_click;

View File

@@ -49,7 +49,7 @@ namespace nana
overrided_ &= ~(1 << static_cast<int>(event_code::move));
}
void drawer_trigger::click(graph_reference, const arg_mouse&)
void drawer_trigger::click(graph_reference, const arg_click&)
{
overrided_ &= ~(1 << static_cast<int>(event_code::click));
}
@@ -155,7 +155,7 @@ namespace nana
realizer_->typeface_changed(graphics);
}
void drawer::click(const arg_mouse& arg)
void drawer::click(const arg_click& arg)
{
_m_emit(event_code::click, arg, &drawer_trigger::click);
}

View File

@@ -699,14 +699,17 @@ namespace detail
bool dbl_click = (last_mouse_down_window == msgwnd) && (xevent.xbutton.time - last_mouse_down_time <= 400);
last_mouse_down_time = xevent.xbutton.time;
last_mouse_down_window = msgwnd;
auto new_focus = (msgwnd->flags.take_active ? msgwnd : msgwnd->other.active_window);
if(new_focus && !new_focus->flags.ignore_mouse_focus)
if (Button1 == xevent.xbutton.button) //Sets the focus only if left button is pressed
{
context.event_window = new_focus;
auto kill_focus = brock.wd_manager.set_focus(new_focus, false);
if(kill_focus != new_focus)
brock.wd_manager.do_lazy_refresh(kill_focus, false);
auto new_focus = (msgwnd->flags.take_active ? msgwnd : msgwnd->other.active_window);
if (new_focus && !new_focus->flags.ignore_mouse_focus)
{
context.event_window = new_focus;
auto kill_focus = brock.wd_manager.set_focus(new_focus, false);
if (kill_focus != new_focus)
brock.wd_manager.do_lazy_refresh(kill_focus, false);
}
}
auto retain = msgwnd->together.events_ptr;
@@ -774,7 +777,9 @@ namespace detail
if((arg.button == ::nana::mouse::left_button) && hit)
{
msgwnd->flags.action = mouse_action::over;
arg.evt_code = event_code::click;
arg_click arg;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg.by_mouse = true;
emit_drawer(&drawer::click, msgwnd, arg, &context);
fire_click = true;
}
@@ -794,7 +799,9 @@ namespace detail
if(fire_click)
{
arg.evt_code = event_code::click;
arg_click arg;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg.by_mouse = true;
evt_ptr->click.emit(arg);
}
@@ -806,7 +813,9 @@ namespace detail
}
else if(fire_click)
{
arg.evt_code = event_code::click;
arg_click arg;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg.by_mouse = true;
msgwnd->together.events_ptr->click.emit(arg);
}
brock.wd_manager.do_lazy_refresh(msgwnd, false);

View File

@@ -949,12 +949,16 @@ namespace detail
if(msgwnd->flags.enabled)
{
pressed_wd = msgwnd;
auto new_focus = (msgwnd->flags.take_active ? msgwnd : msgwnd->other.active_window);
if(new_focus && (!new_focus->flags.ignore_mouse_focus))
if (WM_LBUTTONDOWN == message) //Sets focus only if left button is pressed
{
auto kill_focus = brock.wd_manager.set_focus(new_focus, false);
if(kill_focus != new_focus)
brock.wd_manager.do_lazy_refresh(kill_focus, false);
auto new_focus = (msgwnd->flags.take_active ? msgwnd : msgwnd->other.active_window);
if (new_focus && (!new_focus->flags.ignore_mouse_focus))
{
auto kill_focus = brock.wd_manager.set_focus(new_focus, false);
if (kill_focus != new_focus)
brock.wd_manager.do_lazy_refresh(kill_focus, false);
}
}
arg_mouse arg;
@@ -1007,7 +1011,9 @@ namespace detail
msgwnd->flags.action = mouse_action::over;
if (::nana::mouse::left_button == arg.button)
{
arg.evt_code = event_code::click;
arg_click arg;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg.by_mouse = true;
emit_drawer(&drawer::click, msgwnd, arg, &context);
fire_click = true;
}
@@ -1021,7 +1027,9 @@ namespace detail
if (fire_click)
{
arg.evt_code = event_code::click;
arg_click arg;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg.by_mouse = true;
retain->click.emit(arg);
}
@@ -1033,7 +1041,9 @@ namespace detail
}
else if (fire_click)
{
arg.evt_code = event_code::click;
arg_click arg;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg.by_mouse = true;
retain->click.emit(arg);
}
brock.wd_manager.do_lazy_refresh(msgwnd, false);