本文整理汇总了C++中ListPtr::getSelectionModel方法的典型用法代码示例。如果您正苦于以下问题:C++ ListPtr::getSelectionModel方法的具体用法?C++ ListPtr::getSelectionModel怎么用?C++ ListPtr::getSelectionModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListPtr
的用法示例。
在下文中一共展示了ListPtr::getSelectionModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectionChanged
virtual void selectionChanged(const ListSelectionEventPtr e)
{
if(ExampleList->getSelectionModel()->getMinSelectionIndex() != -1)
{
beginEditCP(DetailsWindow, TextArea::TextFieldMask);
DetailsWindow->setText(GenericInventoryItem::Ptr::dcast(ExampleInventory->getInventoryItems(ExampleList->getSelectionModel()->getMinSelectionIndex()))->getDetails());
endEditCP(DetailsWindow, TextArea::TextFieldMask);
}
}
示例2: main
//.........这里部分代码省略.........
Create ListCellRenderer and
ListSelectionModel. Most
often the defauls will be used.
Note: the ListSelectionModel was
created above and is referenced
by the ActionListeners.
******************************************************/
/******************************************************
Create List itself and assign its
Model, CellRenderer, and SelectionModel
to it.
-setOrientation(ENUM): Determine the
Layout of the cells (Horizontal
or Vertical). Takes List::VERTICAL_ORIENTATION
and List::HORIZONTAL_ORIENTATION arguments.
******************************************************/
ExampleList = List::create();
beginEditCP(ExampleList, List::PreferredSizeFieldMask | List::OrientationFieldMask | List::ModelFieldMask);
ExampleList->setPreferredSize(Vec2f(200, 300));
ExampleList->setOrientation(List::VERTICAL_ORIENTATION);
//ExampleList->setOrientation(List::HORIZONTAL_ORIENTATION);
ExampleList->setModel(ExampleListModel);
endEditCP(ExampleList, List::PreferredSizeFieldMask | List::OrientationFieldMask | List::ModelFieldMask);
ExampleList->setSelectionModel(ExampleListSelectionModel);
InventoryListListener TheInventoryListListener;
ExampleList->getSelectionModel()->addListSelectionListener(&TheInventoryListListener);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerPtr MainInternalWindowBackground = osg::ColorLayer::create();
beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
/******************************************************
Determine the SelectionModel
-SINGLE_SELECTION lets you select ONE item
via a single mouse click
-SINGLE_INTERVAL_SELECTION lets you select
one interval via mouse and SHIFT key
-MULTIPLE_INTERVAL_SELECTION lets you select
via mouse, and SHIFT and CONTRL keys
Note: this tutorial is currently set up
to allow for this to be changed via
TogggleButtons with ActionListeners attached
to them so this code is commented out.
******************************************************/
//SelectionModel.setMode(DefaultListSelectionModel::SINGLE_SELECTION);
//SelectionModel.setMode(DefaultListSelectionModel::SINGLE_INTERVAL_SELECTION);
//SelectionModel.setMode(DefaultListSelectionModel::MULTIPLE_INTERVAL_SELECTION);
// Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
ScrollPanelPtr ExampleScrollPanel = ScrollPanel::create();