示例#1
0
/** BroadCast Mouse Idle Event */
void EventMgr::MouseIdle(unsigned long /*time*/)
{
	if (last_win_over == NULL) return;
	Control *ctrl = last_win_over->GetOver();
	if (ctrl == NULL) return;
	ctrl->DisplayTooltip();
}
示例#2
0
/** 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 );
	}
}