Exemplo n.º 1
0
/*************************************************************************
	Handler for cursor activation events
*************************************************************************/
void ComboDropList::onCursorActivate(CursorInputEventArgs& e)
{
    ListWidget::onCursorActivate(e);

    if (e.source == CIS_Left)
	{
		if (d_armed && (getChildAtPosition(e.position) == 0))
		{
            // if something was selected, confirm that selection.
            if (getIndexSelectionStates().size() > 0)
            {
                WindowEventArgs args(this);
                onListSelectionAccepted(args);
            }

            releaseInput();
		}
        // if we are not already armed, in response to a left cursor activation event, we auto-arm.
		else
		{
			d_armed = true;
		}

		++e.handled;
	}

}
Exemplo n.º 2
0
/*************************************************************************
	Handler for selections made in the drop-list
*************************************************************************/
bool Combobox::droplist_SelectionAcceptedHandler(const EventArgs& e)
{
	// copy the text from the selected item into the edit box
	ListboxItem* item = ((ComboDropList*)((WindowEventArgs&)e).window)->getFirstSelectedItem();

	if (item != NULL)
	{
		// Put the text from the list item into the edit box
		d_editbox->setText(item->getText());

		// select text if it's editable, and move carat to end
		if (!isReadOnly())
		{
			d_editbox->setSelection(0, item->getText().length());
			d_editbox->setCaratIndex(item->getText().length());
		}

		d_editbox->setCaratIndex(0);

		// fire off an event of our own
		WindowEventArgs args(this);
		onListSelectionAccepted(args);

		// finally, activate the edit box
		d_editbox->activate();
	}

	return true;
}
Exemplo n.º 3
0
/*************************************************************************
	Handler for mouse button release events
*************************************************************************/
void ComboDropList::onMouseButtonUp(MouseEventArgs& e)
{
	Listbox::onMouseButtonUp(e);

	if (e.button == LeftButton)
	{
		if (d_armed && (getChildAtPosition(e.position) == 0))
		{
			// if something was selected, confirm that selection.
			if (getSelectedCount() > 0)
			{
				WindowEventArgs args(this);
				onListSelectionAccepted(args);
			}

            releaseInput();
		}
		// if we are not already armed, in response to a left button up event, we auto-arm.
		else
		{
			d_armed = true;
		}

		++e.handled;
	}

}