Exemple #1
0
bool GUI::handleKeyDown(const EventArgs& eventArgs)
{
    // get the text entry editbox
    Editbox *editbox = static_cast<Editbox *> (guiConsole->getChild(EntryBoxID));
    
    switch (static_cast<const KeyEventArgs&> (eventArgs).scancode) {
        case Key::ArrowUp:
            historyPosition = ceguimax(historyPosition - 1, -1);
            if (historyPosition >= 0) {
                editbox->setText(history[historyPosition]);
                editbox->setCaratIndex(static_cast<size_t> (-1));
            } else
                editbox->setText("");
            
            editbox->activate();
            break;
            
        case Key::ArrowDown:
            historyPosition = ceguimin(historyPosition + 1, static_cast<int> (history.size()));
            if (historyPosition < static_cast<int> (history.size())) {
                editbox->setText(history[historyPosition]);
                editbox->setCaratIndex(static_cast<size_t> (-1));
            } else
                editbox->setText("");
            
            editbox->activate();
            break;
            
        default:
            return false;
	}
    
    return true;
}
bool GUIApplication::onConsoleClicked(const CEGUI::EventArgs& a)
{
    Editbox* inputBox = static_cast<Editbox*>(m_guiContext->getRootWindow()->getChild("console/input"));
    //m_guiContext->setInputCaptureWindow(inputBox);
    inputBox->activate();
    return true;
}
Exemple #3
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;
}
Exemple #4
0
/*************************************************************************
	Activate the edit box component of the Combobox.
*************************************************************************/
void Combobox::activateEditbox(void)
{
    Editbox* editbox = getEditbox();

	if (!editbox->isActive())
	{
		editbox->activate();
	}
}
Exemple #5
0
    void Spinner::onActivated(ActivationEventArgs& e)
    {
        if (!isActive())
        {
            Window::onActivated(e);

            Editbox* editbox = getEditbox();

            if (!editbox->isActive())
            {
                editbox->activate();
            }
        }
    }
void GUIApplication::hudGotFocus()
{
    AnimationManager& animManager = AnimationManager::getSingleton();
    for (Window* w : m_animHideTargets)
    {
        if (!w->isVisible())
            continue;
        AnimationInstance* myAnimInstance = animManager.instantiateAnimation("AreaAnimationShow");
        myAnimInstance->setTargetWindow(w);
        myAnimInstance->start();
    }
    m_animHideTargets.clear();

    m_guiContext->getRootWindow()->getChild("console")->show();
    Editbox* inputBox = static_cast<Editbox*>(m_guiContext->getRootWindow()->getChild("console/input"));
    inputBox->activate();
}
//----------------------------------------------------------------------------//
bool EditboxValidationSample::initialise(CEGUI::GUIContext* guiContext)
{
    using namespace CEGUI;

    d_usedFiles = CEGUI::String(__FILE__);

    // load font and setup default if not loaded via scheme
    FontManager::FontList loadedFonts = FontManager::getSingleton().createFromFile("DejaVuSans-12.font");
    Font* defaultFont = loadedFonts.empty() ? 0 : loadedFonts.front();
    // Set default font for the gui context
    guiContext->setDefaultFont(defaultFont);

    SchemeManager::getSingleton().createFromFile("AlfiskoSkin.scheme");
    guiContext->getCursor().setDefaultImage("AlfiskoSkin/MouseArrow");
    WindowManager& winMgr = WindowManager::getSingleton();

    Window* root = winMgr.createWindow("DefaultWindow");
    guiContext->setRootWindow(root);

    Window* wnd = root->createChild("AlfiskoSkin/FrameWindow");
    wnd->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
    wnd->setSize(USize(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
    wnd->setText("Editbox Validation Sample");

    Window* label = wnd->createChild("AlfiskoSkin/Label");
    label->setProperty("HorzFormatting", "WordWrapCentreAligned");
    label->setSize(USize(cegui_reldim(1.0f), cegui_reldim(0.2f)));
    label->setText("Enter 4 digits into the Editbox. A valid entry will be "
        "[colour='FF00FF00']green, [colour='FFFFFFFF']an invalid entry will be "
        "[colour='FFFF0000']red [colour='FFFFFFFF']and a partially valid entry "
        "will be [colour='FFFFBB11']orange");

    Editbox* eb = static_cast<Editbox*>(wnd->createChild("AlfiskoSkin/Editbox"));
    eb->setPosition(UVector2(cegui_reldim(0.1f), cegui_reldim(0.25f)));
    eb->setSize(USize(cegui_reldim(0.8f), cegui_reldim(0.15f)));
    eb->subscribeEvent(
        Editbox::EventTextValidityChanged,
        Event::Subscriber(&EditboxValidationSample::validationChangeHandler, this));

    eb->setValidationString("[0-9]{4}");
    eb->activate();

    return true;
}
Exemple #8
0
bool GUI::handleSubmit(const EventArgs& eventArgs)
{
    // get the text entry editbox
    Editbox *editbox = static_cast<Editbox *> (guiConsole->getChild(EntryBoxID));
    // get text out of the editbox
    CEGUI::String edit_text(editbox->getText());
    // if the string is not empty
    if (!edit_text.empty()) {
        // add this entry to the command history buffer
        history.push_back(edit_text);
        // reset history position
        historyPosition = history.size();
        // this is the member function that the agent uses to send the text to the brain
        agent->handleText(editbox->getText().c_str());
        // erase text in text entry box.
        editbox->setText("");
    }
    
    // re-activate the text entry box
    editbox->activate();
    
    return true;
}
//----------------------------------------------------------------------------//
bool EditboxValidation::initialiseSample()
{
    using namespace CEGUI;

    SchemeManager::getSingleton().createFromFile("AlfiskoSkin.scheme");
    System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("AlfiskoSkin/MouseArrow");
    WindowManager& winMgr = WindowManager::getSingleton();

    Window* root = winMgr.createWindow("DefaultWindow");
    System::getSingleton().getDefaultGUIContext().setRootWindow(root);

    Window* wnd = root->createChild("AlfiskoSkin/FrameWindow");
    wnd->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
    wnd->setSize(USize(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
    wnd->setText("Editbox Validation Demo");

    Window* label = wnd->createChild("AlfiskoSkin/Label");
    label->setProperty("HorzFormatting", "WordWrapCentreAligned");
    label->setSize(USize(cegui_reldim(1.0f), cegui_reldim(0.2f)));
    label->setText("Enter 4 digits into the Editbox. A valid entry will be "
        "[colour='FF00FF00']green, [colour='FFFFFFFF']an invalid entry will be "
        "[colour='FFFF0000']red [colour='FFFFFFFF']and a partially valid entry "
        "will be [colour='FFFFBB11']orange");

    Editbox* eb = static_cast<Editbox*>(wnd->createChild("AlfiskoSkin/Editbox"));
    eb->setPosition(UVector2(cegui_reldim(0.1f), cegui_reldim(0.25f)));
    eb->setSize(USize(cegui_reldim(0.8f), cegui_reldim(0.15f)));
    eb->subscribeEvent(
        Editbox::EventTextValidityChanged,
        Event::Subscriber(&EditboxValidation::validationChangeHandler, this));

    eb->setValidationString("[0-9]{4}");
    eb->activate();

    return true;
}