Exemple #1
0
	void Manager::OnMouseLeftDown(System::Event* event)
	{
		System::MouseLeftButtonDownEvent* e = static_cast<System::MouseLeftButtonDownEvent*>(event);
		Widget* newFocuseWidget = 0;
		for (auto it = rootWidgets.begin(); it != rootWidgets.end(); it++)
		{
			if (!(*it)->IsVisible() || !(*it)->IsEnabled())
				continue;

			if ((*it)->IsPointIn(Widget::WindowToViewport(float(e->x), float(e->y))))
			{
				newFocuseWidget = (*it)->GetFocused(float(e->x), float(e->y));
				(*it)->OnMouseLeftButtonDown(e);
				break;
			}
		}
		if (newFocuseWidget)
		{
			out_message() << newFocuseWidget->GetText() << std::endl;
			if (m_focusWidget)
			{
				GUI::SetUnFocusedEvent* unfocuseEvent = new GUI::SetUnFocusedEvent;
				unfocuseEvent->anyData = m_focusWidget;
				m_adapter->OnSetUnFocusedEvent(unfocuseEvent);
				m_focusWidget->SetFocuse(false);					
			}

			SetFocusedEvent* focuseEvent = new SetFocusedEvent;
			focuseEvent->anyData = newFocuseWidget;
			m_adapter->OnSetFocusedEvent(focuseEvent);

			newFocuseWidget->SetFocuse(true);
			m_focusWidget = newFocuseWidget;
			m_focusWidget->OnMouseLeftButtonDown(e);					
		}
	}
Exemple #2
0
	void MousePressed(Widget &b, int x, int y, bool isLeft)
	{
		_w.SetText(b.GetText());
		_w.Hide();
	}