Exemplo n.º 1
0
bool TreeSample::handleEventSelectionChanged(const CEGUI::EventArgs& args)
{
    using namespace CEGUI;

    const ItemViewEventArgs& treeArgs = static_cast<const ItemViewEventArgs&>(args);
    Editbox *editBox = (Editbox *)d_rootWindow->getChild(EditBoxID);

    TreeWidget* tree = static_cast<TreeWidget*>(treeArgs.window);
    // Three different ways to get the item selected.
    //   TreeCtrlEntry *selectedItem = theTree->getFirstSelectedItem();      // the first selection in the list (may be more)
    //   TreeCtrlEntry *selectedItem = theTree->getLastSelectedItem();       // the last (time-wise) selected by the user
    StandardItem* selectedItem = tree->getModel()->getItemForIndex(treeArgs.d_index);                    // the actual item that caused this event

    if (selectedItem)
    {
#if 0
        // A convoluted way to get the item text.
        // Just here to test findFirstItemWithText.
        selectedItem = theTree->findFirstItemWithText(selectedItem->getText());
        if (selectedItem)
            editBox->setText("Selected: " + selectedItem->getText());
        else
            editBox->setText("findItemWithText failed!");
#else
        // The simple way to do it.
        editBox->setText("Selected: " + selectedItem->getText());
#endif
    }
    else
        editBox->setText("None Selected");

    return true;
}
Exemplo n.º 2
0
bool MenuNavigationSample::handleSelectButtonClicked(const CEGUI::EventArgs&)
{
    using namespace CEGUI;

    StandardItem* item = d_classesList->getFirstSelectedItem();
    if (item != 0)
    {
        d_logWidget2->setText("Selected " + item->getText() + "\n");
    }

    return true;
}
Exemplo n.º 3
0
void FontsSample::changeFontSelectorFontSelection(const CEGUI::String& font)
{
    d_fontSelector->clearSelections();

    unsigned int itemCount = d_fontSelector->getItemCount();
    for (unsigned int i = 0; i < itemCount; ++i)
    {
        StandardItem* item = d_fontSelector->getItemAtIndex(i);
        String itemFontName = item->getText();

        if (itemFontName.compare(font) == 0)
        {
            d_fontSelector->setIndexSelectionState(i, true);
            return;
        }
    }
}