示例#1
0
//! called if an event happened.
bool CGUIMenu::OnEvent(SEvent event)
{
	if (!IsEnabled)
		return Parent ? Parent->OnEvent(event) : false;

	switch(event.EventType)
	{
	case EET_GUI_EVENT:
		switch(event.GUIEvent.EventType)
		{
		case gui::EGET_ELEMENT_FOCUS_LOST:
			if (event.GUIEvent.Caller == (IGUIElement*)this)
				closeAllSubMenus();
            return true;
		}
		break;
	case EET_MOUSE_INPUT_EVENT:
		switch(event.MouseInput.Event)
		{
		case EMIE_LMOUSE_LEFT_UP:
			{
				core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
				if (AbsoluteClippingRect.isPointInside(p))
				{
					if (HighLighted != -1)
						Environment->removeFocus(this);
					else
						highlight(core::position2d<s32>(event.MouseInput.X,	event.MouseInput.Y));
				}
				else
				{
					s32 t = sendClick(p);
					if ((t==0 || t==1) && Environment->hasFocus(this))
						Environment->removeFocus(this);
				}
			}
			return true;
		case EMIE_LMOUSE_PRESSED_DOWN:
			if (!Environment->hasFocus(this))
			{
				Environment->setFocus(this);
				if (Parent)
					Parent->bringToFront(this);
			}
			return true;
		case EMIE_MOUSE_MOVED:
			if (Environment->hasFocus(this))
				highlight(core::position2d<s32>(event.MouseInput.X,	event.MouseInput.Y));
			return true;
		}
		break;
	}

	return Parent ? Parent->OnEvent(event) : false;
}
示例#2
0
//! called if an event happened.
bool CGUIMenu::OnEvent(const SEvent& event)
{
	if (!IsEnabled)
		return Parent ? Parent->OnEvent(event) : false;

	switch(event.EventType)
	{
	case EET_GUI_EVENT:
		switch(event.GUIEvent.EventType)
		{
		case gui::EGET_ELEMENT_FOCUS_LOST:
			if (event.GUIEvent.Caller == this && !isMyChild(event.GUIEvent.Element))
			{
				closeAllSubMenus();
				HighLighted = -1;
			}
			break;
		case gui::EGET_ELEMENT_FOCUSED:
			if (event.GUIEvent.Caller == this && Parent)
			{
				Parent->bringToFront(this);
			}
			break;
		default:
			break;
		}
		break;
	case EET_MOUSE_INPUT_EVENT:
		switch(event.MouseInput.Event)
		{
		case EMIE_LMOUSE_PRESSED_DOWN:
		{
			if (!Environment->hasFocus(this))
			{
				Environment->setFocus(this);
			}

			if (Parent)
				Parent->bringToFront(this); 

			core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
			bool shouldCloseSubMenu = hasOpenSubMenu();
			if (!AbsoluteClippingRect.isPointInside(p))
			{
				shouldCloseSubMenu = false;
				s32 t = sendClick(p);
				if ((t==0 || t==1) && Environment->hasFocus(this))
					Environment->removeFocus(this);
			}
			highlight(core::position2d<s32>(event.MouseInput.X,	event.MouseInput.Y), true);
			if ( shouldCloseSubMenu )
				closeAllSubMenus();
			
			return true;
		}
		case EMIE_MOUSE_MOVED:
			if (Environment->hasFocus(this))
				highlight(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y), hasOpenSubMenu());
			return true;
		default:
			break;
		}
		break;
	default:
		break;
	}

	return Parent ? Parent->OnEvent(event) : false;
}
示例#3
0
	//! called if an event happened.
	bool CGUIMenu::OnEvent(const SEvent& event)
	{
		if (isEnabled())
		{

			switch (event.EventType)
			{
			case EET_GUI_EVENT:
				switch (event.GUIEvent.EventType)
				{
				case EGET_ELEMENT_FOCUS_LOST:
					if (event.GUIEvent.Caller == this && !isMyChild(event.GUIEvent.Element))
					{
						closeAllSubMenus();
						HighLighted = -1;
					}
					break;
				case EGET_ELEMENT_FOCUSED:
					if (event.GUIEvent.Caller == this && Parent)
					{
						Parent->bringToFront(this);
					}
					break;
				default:
					break;
				}
				break;
			case EET_MOUSE_INPUT_EVENT:
				switch (event.MouseInput.Event)
				{
				case EMIE_LMOUSE_PRESSED_DOWN:
				{
					if (!Environment->hasFocus(this))
					{
						Environment->setFocus(this);
					}

					if (Parent)
						Parent->bringToFront(this);

					Position2d p(event.MouseInput.X, event.MouseInput.Y);
					bool shouldCloseSubMenu = hasOpenSubMenu();
					if (!AbsoluteClippingRect.isPointInside(p))
					{
						shouldCloseSubMenu = false;
					}
					highlight(Position2d(event.MouseInput.X, event.MouseInput.Y), true);
					if (shouldCloseSubMenu)
					{
						Environment->removeFocus(this);
					}

					return true;
				}
				case EMIE_LMOUSE_LEFT_UP:
				{
					Position2d p(event.MouseInput.X, event.MouseInput.Y);
					if (!AbsoluteClippingRect.isPointInside(p))
					{
						SINT32 t = sendClick(p);
						if ((t == 0 || t == 1) && Environment->hasFocus(this))
							Environment->removeFocus(this);
					}

					return true;
				}
				case EMIE_MOUSE_MOVED:
					if (Environment->hasFocus(this) && HighLighted >= 0)
					{
						SINT32 oldHighLighted = HighLighted;
						highlight(Position2d(event.MouseInput.X, event.MouseInput.Y), true);
						if (HighLighted < 0)
							HighLighted = oldHighLighted;   // keep last hightlight active when moving outside the area
					}
					return true;
				default:
					break;
				}
				break;
			default:
				break;
			}
		}

		return IGUIElement::OnEvent(event);
	}