Added wxKeyEvent::IsKeyInCategory() method.

This allows to test whether a given key belongs to the category of e.g. arrow
keys or navigation keys in a more concise and more readable manner.

Closes #10268.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61736 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-08-23 00:32:17 +00:00
parent 2e4d0e91bf
commit 7a34307e24
6 changed files with 114 additions and 20 deletions

View File

@@ -752,6 +752,45 @@ wxKeyEvent::wxKeyEvent(const wxKeyEvent& evt)
#endif
}
bool wxKeyEvent::IsKeyInCategory(int category) const
{
switch ( GetKeyCode() )
{
case WXK_LEFT:
case WXK_RIGHT:
case WXK_UP:
case WXK_DOWN:
case WXK_NUMPAD_LEFT:
case WXK_NUMPAD_RIGHT:
case WXK_NUMPAD_UP:
case WXK_NUMPAD_DOWN:
return (category & WXK_CATEGORY_ARROW) != 0;
case WXK_PAGEDOWN:
case WXK_END:
case WXK_NUMPAD_PAGEUP:
case WXK_NUMPAD_PAGEDOWN:
return (category & WXK_CATEGORY_PAGING) != 0;
case WXK_HOME:
case WXK_PAGEUP:
case WXK_NUMPAD_HOME:
case WXK_NUMPAD_END:
return (category & WXK_CATEGORY_JUMP) != 0;
case WXK_TAB:
return (category & WXK_CATEGORY_TAB) != 0;
case WXK_BACK:
case WXK_DELETE:
case WXK_NUMPAD_DELETE:
return (category & WXK_CATEGORY_CUT) != 0;
default:
return false;
}
}
// ----------------------------------------------------------------------------
// wxWindowCreateEvent
// ----------------------------------------------------------------------------