コード例 #1
0
	void EditorWidgetManager::update()
	{
		if (gInput().isPointerButtonDown(PointerEventButton::Left) || gInput().isPointerButtonDown(PointerEventButton::Right))
		{
			for (auto& widgetData : mActiveWidgets)
			{
				EditorWidgetBase* widget = widgetData.second;
				EditorWidgetContainer* parentContainer = widget->_getParent();
				if (parentContainer == nullptr)
				{
					widget->_setHasFocus(false);
					continue;
				}

				EditorWindowBase* parentWindow = parentContainer->getParentWindow();
				SPtr<RenderWindow> parentRenderWindow = parentWindow->getRenderWindow();
				const RenderWindowProperties& props = parentRenderWindow->getProperties();

				if (!props.hasFocus())
				{
					widget->_setHasFocus(false);
					continue;
				}

				if (parentContainer->getActiveWidget() != widget)
				{
					widget->_setHasFocus(false);
					continue;
				}

				Vector2I widgetPos = widget->screenToWidgetPos(gInput().getPointerPosition());
				if (widgetPos.x >= 0 && widgetPos.y >= 0
					&& widgetPos.x < (INT32)widget->getWidth()
					&& widgetPos.y < (INT32)widget->getHeight())
				{
					widget->_setHasFocus(true);
				}
				else
					widget->_setHasFocus(false);
			}
		}
	}