本文整理汇总了C++中Control::OnSpecialKeyPress方法的典型用法代码示例。如果您正苦于以下问题:C++ Control::OnSpecialKeyPress方法的具体用法?C++ Control::OnSpecialKeyPress怎么用?C++ Control::OnSpecialKeyPress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Control
的用法示例。
在下文中一共展示了Control::OnSpecialKeyPress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnSpecialKeyPress
/** Special Key Press Event */
void EventMgr::OnSpecialKeyPress(unsigned char Key)
{
if (!last_win_focused) {
return;
}
Control *ctrl = NULL;
// tab shows tooltips
if (Key == GEM_TAB) {
if (last_win_over != NULL) {
Control *ctrl = last_win_over->GetOver();
if (ctrl != NULL) {
ctrl->DisplayTooltip();
}
}
}
//the default control will get only GEM_RETURN
else if (Key == GEM_RETURN) {
ctrl = last_win_focused->GetDefaultControl(0);
}
//the default cancel control will get only GEM_ESCAPE
else if (Key == GEM_ESCAPE) {
ctrl = last_win_focused->GetDefaultControl(1);
} else if (Key >= GEM_FUNCTION1 && Key <= GEM_FUNCTION16) {
if (function_bar) {
ctrl = function_bar->GetFunctionControl(Key-GEM_FUNCTION1);
} else {
ctrl = last_win_focused->GetFunctionControl(Key-GEM_FUNCTION1);
}
}
//if there was no default button set, then the current focus will get it (except function keys)
if (!ctrl) {
if (Key<GEM_FUNCTION1 || Key > GEM_FUNCTION16) {
ctrl = last_win_focused->GetFocus();
}
}
//if one is under focus, use the default scroll focus
if (!ctrl) {
if (Key == GEM_UP || Key == GEM_DOWN) {
ctrl = last_win_focused->GetScrollControl();
}
}
if (ctrl) {
switch (ctrl->ControlType) {
//scrollbars will receive only mousewheel events
case IE_GUI_SCROLLBAR:
if (Key != GEM_UP && Key != GEM_DOWN) {
return;
}
break;
//buttons will receive only GEM_RETURN
case IE_GUI_BUTTON:
if (Key >= GEM_FUNCTION1 && Key <= GEM_FUNCTION16) {
//fake mouse button
ctrl->OnMouseDown(0,0,GEM_MB_ACTION,0);
ctrl->OnMouseUp(0,0,GEM_MB_ACTION,0);
return;
}
if (Key != GEM_RETURN && Key!=GEM_ESCAPE) {
return;
}
break;
case IE_GUI_GAMECONTROL:
case IE_GUI_WORLDMAP:
//gamecontrols will receive all special keys
break;
case IE_GUI_EDIT:
case IE_GUI_TEXTAREA:
//editboxes and textareas will receive all special keys
break;
default:
//other controls don't receive any
return;
}
ctrl->OnSpecialKeyPress( Key );
}
}