示例#1
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)
	{
        Editbox* editbox = getEditbox();
		// Put the text from the list item into the edit box
		editbox->setText(item->getText());

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

		editbox->setCaretIndex(0);
		editbox->activate();

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

	return true;
}
void SelectionLength::set(PropertyReceiver* receiver, const String& value)
{
	Editbox* eb = static_cast<Editbox*>(receiver);
	uint selLen = PropertyHelper::stringToUint(value);
	eb->setSelection(eb->getSelectionStartIndex(), eb->getSelectionStartIndex() + selLen);
}
void SelectionStart::set(PropertyReceiver* receiver, const String& value)
{
	Editbox* eb = static_cast<Editbox*>(receiver);
	uint selStart = PropertyHelper::stringToUint(value);
	eb->setSelection(selStart, selStart + eb->getSelectionLength());
}