ensure click event consistency

the order of click events generated by mouse and keyboard are different
This commit is contained in:
Jinhao 2018-06-23 06:16:19 +08:00
parent feaa0d1ec1
commit 5f703bff4c
4 changed files with 51 additions and 46 deletions

View File

@ -79,7 +79,9 @@ namespace drawerbase
void element_set(const char* name);
void react(bool want); ///< Enables the reverse check while clicking on the checkbox.
bool checked() const;
void check(bool chk);
/// Checks/unchecks the checkbox
void check(bool state);
/// \brief With the radio mode, users make a choice among a set of mutually exclusive,
/// related options. Users can choose one and only one option.

View File

@ -1149,28 +1149,29 @@ namespace detail
{
msgwnd->set_action(mouse_action::normal);
arg_click click_arg;
click_arg.mouse_args = nullptr;
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
auto retain = msgwnd->annex.events_ptr;
auto retain = msgwnd->annex.events_ptr;
if (brock.emit(event_code::click, msgwnd, click_arg, true, &context))
{
arg_mouse arg;
arg.alt = false;
arg.button = ::nana::mouse::left_button;
arg.ctrl = false;
arg.evt_code = event_code::mouse_up;
arg.left_button = true;
arg.mid_button = false;
arg.pos.x = 0;
arg.pos.y = 0;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg_click click_arg;
click_arg.mouse_args = nullptr;
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
draw_invoker(&drawer::mouse_up, msgwnd, arg, &context);
wd_manager.do_lazy_refresh(msgwnd, false);
}
pressed_wd_space = nullptr;
arg_mouse arg;
arg.alt = false;
arg.button = ::nana::mouse::left_button;
arg.ctrl = false;
arg.evt_code = event_code::mouse_up;
arg.left_button = true;
arg.mid_button = false;
arg.pos.x = 0;
arg.pos.y = 0;
arg.window_handle = reinterpret_cast<window>(msgwnd);
draw_invoker(&drawer::mouse_up, msgwnd, arg, &context);
if (brock.emit(event_code::click, msgwnd, click_arg, true, &context))
wd_manager.do_lazy_refresh(msgwnd, false);
pressed_wd_space = nullptr;
}
else
{

View File

@ -1495,38 +1495,40 @@ namespace detail
{
msgwnd->set_action(mouse_action::normal);
auto retain = msgwnd->annex.events_ptr;
arg_click click_arg;
click_arg.mouse_args = nullptr;
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
auto retain = msgwnd->annex.events_ptr;
if (brock.emit(event_code::click, msgwnd, click_arg, true, &context))
{
arg_mouse arg;
arg.alt = false;
arg.button = ::nana::mouse::left_button;
arg.ctrl = false;
arg.evt_code = event_code::mouse_up;
arg.left_button = true;
arg.mid_button = false;
arg.pos.x = 0;
arg.pos.y = 0;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg_mouse arg;
arg.alt = false;
arg.button = ::nana::mouse::left_button;
arg.ctrl = false;
arg.evt_code = event_code::mouse_up;
arg.left_button = true;
arg.mid_button = false;
arg.pos.x = 0;
arg.pos.y = 0;
arg.window_handle = reinterpret_cast<window>(msgwnd);
draw_invoker(&drawer::mouse_up, msgwnd, arg, &context);
draw_invoker(&drawer::mouse_up, msgwnd, arg, &context);
if (brock.emit(event_code::click, msgwnd, click_arg, true, &context))
wd_manager.do_lazy_refresh(msgwnd, false);
}
pressed_wd_space = nullptr;
}
else
{
arg_keyboard arg;
arg.evt_code = event_code::key_release;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg.key = translate_virtual_key(wParam);
brock.get_key_state(arg);
arg.ignore = false;
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
arg_keyboard keyboard_arg;
keyboard_arg.evt_code = event_code::key_release;
keyboard_arg.window_handle = reinterpret_cast<window>(msgwnd);
keyboard_arg.key = translate_virtual_key(wParam);
brock.get_key_state(keyboard_arg);
keyboard_arg.ignore = false;
brock.emit(event_code::key_release, msgwnd, keyboard_arg, true, &context);
}
}
}

View File

@ -167,12 +167,12 @@ namespace nana{ namespace drawerbase
return (get_drawer_trigger().impl()->crook.checked() != drawerbase::checkbox::crook_state::unchecked);
}
void checkbox::check(bool chk)
void checkbox::check(bool state)
{
using crook_state = drawerbase::checkbox::crook_state;
if (checked() != chk)
if (checked() != state)
{
get_drawer_trigger().impl()->crook.check(chk ? crook_state::checked : crook_state::unchecked);
get_drawer_trigger().impl()->crook.check(state ? crook_state::checked : crook_state::unchecked);
API::refresh_window(handle());
arg_checkbox arg(this);