Ejemplo n.º 1
0
/*************************************************************************
	Handler for mouse movement events
*************************************************************************/
void ComboDropList::onMouseMove(MouseEventArgs& e)
{
	Listbox::onMouseMove(e);

	// if mouse is within our area (but not our children)
	if (isHit(e.position))
	{
		if (!getChildAtPosition(e.position))
		{
			// handle auto-arm
			if (d_autoArm)
			{
				d_armed = true;
			}

			if (d_armed)
			{
				//
				// Convert mouse position to absolute window pixels
				//
				Point localPos(CoordConverter::screenToWindow(*this, e.position));

				// check for an item under the mouse
				ListboxItem* selItem = getItemAtPoint(localPos);

				// if an item is under mouse, select it
				if (selItem)
				{
					setItemSelectState(selItem, true);
				}
				else
				{
					clearAllSelections();
				}

			}
		}

		e.handled = true;
	}
	// not within the list area
	else
	{
		// if left mouse button is down, clear any selection
		if (e.sysKeys & LeftMouse)
		{
			clearAllSelections();
		}

	}

}
Ejemplo n.º 2
0
/*************************************************************************
	Set the select state of an attached ListboxItem.
*************************************************************************/
void Listbox::setItemSelectState(ListboxItem* item, bool state)
{
	LBItemList::iterator pos = std::find(d_listItems.begin(), d_listItems.end(), item);

	if (pos != d_listItems.end())
	{
		setItemSelectState(std::distance(d_listItems.begin(), pos), state);
	}
	else
	{
		CEGUI_THROW(InvalidRequestException("Listbox::setItemSelectState - the specified ListboxItem is not attached to this Listbox."));
	}
}
Ejemplo n.º 3
0
/*************************************************************************
	Handler for when input capture is lost
*************************************************************************/
void ComboDropList::onCaptureLost(WindowEventArgs& e)
{
	Listbox::onCaptureLost(e);
	d_armed = false;
	hide();
	++e.handled;

    // ensure 'sticky' selection remains.
    if ((d_lastClickSelected) && !d_lastClickSelected->isSelected())
    {
        clearAllSelections_impl();
        setItemSelectState(d_lastClickSelected, true);
    }
}
Ejemplo n.º 4
0
/*************************************************************************
	Handler for mouse movement events
*************************************************************************/
void ComboDropList::onMouseMove(MouseEventArgs& e)
{
	Listbox::onMouseMove(e);

	// if mouse is within our area (but not our children)
	if (isHit(e.position))
	{
		if (!getChildAtPosition(e.position))
		{
			// handle auto-arm
			if (d_autoArm)
			{
				d_armed = true;
			}

			if (d_armed)
			{
				// check for an item under the mouse
				ListboxItem* selItem = getItemAtPoint(e.position);

				// if an item is under mouse, select it
				if (selItem)
				{
					setItemSelectState(selItem, true);
				}
				else
				{
					clearAllSelections();
				}

			}
		}

		++e.handled;
	}
	// not within the list area
	else
	{
		// if left mouse button is down, clear any selection
		if (e.sysKeys & LeftMouse)
		{
			clearAllSelections();
		}

	}

}