fix bug that DEL key is incorrect in key_press/key_release(#259)
This commit is contained in:
@@ -91,6 +91,8 @@ namespace nana
|
||||
substitute = 0x1A, //Ctrl+Z
|
||||
escape = 0x1B,
|
||||
space = 0x20, //Space
|
||||
del = 0x7F, //Delete
|
||||
os_del = del, //Deprecated
|
||||
|
||||
//The following names are intuitive name of ASCII control codes
|
||||
select_all = start_of_headline,
|
||||
@@ -106,8 +108,8 @@ namespace nana
|
||||
os_ctrl = 0x11,
|
||||
os_pageup = 0x21, os_pagedown,
|
||||
os_arrow_left = 0x25, os_arrow_up, os_arrow_right, os_arrow_down,
|
||||
os_insert = 0x2D, os_del ,
|
||||
os_end = 0x23 , os_home //Pos 1
|
||||
os_insert = 0x2D,
|
||||
os_end = 0x23, os_home //Pos 1
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -438,8 +438,8 @@ namespace detail
|
||||
keysym = keyboard::os_arrow_left + (keysym - XK_Left); break;
|
||||
case XK_Insert:
|
||||
keysym = keyboard::os_insert; break;
|
||||
case XK_Delete:
|
||||
keysym = keyboard::os_del; break;
|
||||
case XK_Delete: case XK_KP_Delete:
|
||||
keysym = keyboard::del; break;
|
||||
case XK_Shift_L: case XK_Shift_R: //shift
|
||||
keysym = keyboard::os_shift; break;
|
||||
case XK_Control_L: case XK_Control_R: //ctrl
|
||||
|
||||
@@ -775,6 +775,19 @@ namespace detail
|
||||
if (thrd) thrd->event_window = prev_event_wd;
|
||||
}
|
||||
|
||||
//Translate OS Virtual-Key into ASCII code
|
||||
wchar_t translate_virtual_key(WPARAM vkey)
|
||||
{
|
||||
switch (vkey)
|
||||
{
|
||||
case VK_DELETE:
|
||||
return 127;
|
||||
case VK_DECIMAL:
|
||||
return 46;
|
||||
}
|
||||
return static_cast<wchar_t>(vkey);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK Bedrock_WIN32_WindowProc(HWND root_window, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT window_proc_value = 0;
|
||||
@@ -1436,7 +1449,7 @@ namespace detail
|
||||
arg.evt_code = event_code::key_press;
|
||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
arg.ignore = false;
|
||||
arg.key = static_cast<wchar_t>(wParam);
|
||||
arg.key = translate_virtual_key(wParam);
|
||||
brock.get_key_state(arg);
|
||||
brock.emit(event_code::key_press, msgwnd, arg, true, &context);
|
||||
|
||||
@@ -1522,7 +1535,7 @@ namespace detail
|
||||
arg_keyboard arg;
|
||||
arg.evt_code = event_code::key_release;
|
||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
arg.key = static_cast<wchar_t>(wParam);
|
||||
arg.key = translate_virtual_key(wParam);
|
||||
brock.get_key_state(arg);
|
||||
arg.ignore = false;
|
||||
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
||||
|
||||
@@ -1233,7 +1233,7 @@ namespace nana{ namespace widgets
|
||||
case keyboard::os_pagedown:
|
||||
_m_handle_move_key(arg);
|
||||
break;
|
||||
case keyboard::os_del:
|
||||
case keyboard::del:
|
||||
// send delete to set_accept function
|
||||
if (this->attr().editable && (!impl_->capacities.pred_acceptive || impl_->capacities.pred_acceptive(key)))
|
||||
del();
|
||||
|
||||
Reference in New Issue
Block a user