MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / addSelection

Method addSelection

Engine/source/gui/controls/guiTreeViewCtrl.cpp:2198–2263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2196//-----------------------------------------------------------------------------
2197
2198void GuiTreeViewCtrl::addSelection( S32 itemOrObjectId, bool update, bool isLastSelection )
2199{
2200 if (mDebug)
2201 Con::printf( "addSelection %i", itemOrObjectId );
2202
2203 Item* item = _findItemByAmbiguousId( itemOrObjectId );
2204
2205 // Add Item?
2206 if ( !item || isSelected( item ) || !canAddSelection( item ) )
2207 {
2208 // Nope.
2209 return;
2210 }
2211
2212 const S32 itemId = item->getID();
2213
2214 // Ok, we have an item to select which isn't already selected....
2215
2216 // Do we want to allow more than one selected item?
2217 if( !mMultipleSelections )
2218 clearSelection();
2219
2220 // Add this object id to the vector of selected objectIds
2221 // if it is not already.
2222 bool foundMatch = false;
2223 for ( S32 i = 0; i < mSelected.size(); i++)
2224 {
2225 if ( mSelected[i] == itemId )
2226 foundMatch = true;
2227 }
2228
2229 if ( !foundMatch )
2230 mSelected.push_front(itemId);
2231
2232 item->mState.set(Item::Selected, true);
2233
2234 if( mSelected.size() == 1 )
2235 {
2236 onItemSelected( item );
2237 }
2238
2239 // Callback Start
2240 // Set and add the selection to the selected items group
2241 item->mState.set(Item::Selected, true);
2242 mSelectedItems.push_front(item);
2243
2244 if ( item->isInspectorData() &&
2245 item->getObject() )
2246 {
2247 SimObject *obj = item->getObject();
2248
2249 onAddSelection_callback( obj->getId(), isLastSelection );
2250 }
2251 else
2252 {
2253 onAddSelection_callback( item->mId, isLastSelection );
2254 }
2255 // Callback end

Callers 1

Calls 10

printfFunction · 0.85
isSelectedFunction · 0.85
canAddSelectionFunction · 0.85
isInspectorDataMethod · 0.80
getIdMethod · 0.65
getIDMethod · 0.45
sizeMethod · 0.45
push_frontMethod · 0.45
setMethod · 0.45
getObjectMethod · 0.45

Tested by

no test coverage detected