@@ -136,6 +136,7 @@ namespace RTEGUI {
136
136
rootCollectionBox->SetDrawBackground (false );
137
137
m_RootControl = rootCollectionBox;
138
138
m_CollectionBoxList->AddItem (m_RootControl->GetName ());
139
+ m_CollectionBoxList->SetSelectedIndex (0 );
139
140
}
140
141
141
142
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -229,14 +230,12 @@ namespace RTEGUI {
229
230
s_SelectionInfo.SetControl (control);
230
231
}
231
232
UpdateCollectionBoxChildrenList (dynamic_cast <GUICollectionBox *>(control));
232
- m_ControlsInCollectionBoxList->SetSelectedIndex (-1 );
233
233
}
234
234
} else {
235
235
// Deselection if clicked on no list item
236
236
ClearCurrentSelection ();
237
237
// When nothing is selected populate the children list with the root control's children to show any "loose" controls
238
238
UpdateCollectionBoxChildrenList (dynamic_cast <GUICollectionBox *>(m_RootControl));
239
- m_ControlsInCollectionBoxList->SetSelectedIndex (-1 );
240
239
}
241
240
RemoveFocus ();
242
241
}
@@ -290,6 +289,9 @@ namespace RTEGUI {
290
289
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
291
290
292
291
void EditorManager::UpdateCollectionBoxList () const {
292
+ // Store the last collection box that was selected before the update so it can be selected if it still exists, if no selection then select root
293
+ std::string lastSelection = (m_CollectionBoxList->GetSelectedIndex () != -1 ) ? m_CollectionBoxList->GetSelected ()->m_Name : " " ;
294
+
293
295
m_CollectionBoxList->ClearList ();
294
296
m_CollectionBoxList->AddItem (m_RootControl->GetName ());
295
297
@@ -305,6 +307,14 @@ namespace RTEGUI {
305
307
for (GUIControl *control : *m_WorkspaceManager->GetControlList ()) {
306
308
if ((collectionBox = dynamic_cast <GUICollectionBox *>(control)) && collectionBox->GetParent () == m_RootControl) { recursiveAddItem (collectionBox, " \t " ); }
307
309
}
310
+
311
+ for (const GUIListBox::Item *listEntry : *m_CollectionBoxList->GetItemList ()) {
312
+ if (listEntry->m_Name == lastSelection) {
313
+ m_CollectionBoxList->SetSelectedIndex (listEntry->m_ID );
314
+ break ;
315
+ }
316
+ m_CollectionBoxList->SetSelectedIndex (0 );
317
+ }
308
318
}
309
319
310
320
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -385,7 +395,7 @@ namespace RTEGUI {
385
395
void EditorManager::ClearCurrentSelection () const {
386
396
s_SelectionInfo.ClearSelection ();
387
397
m_PropertyPage->ClearValues ();
388
- m_CollectionBoxList->SetSelectedIndex (- 1 );
398
+ m_CollectionBoxList->SetSelectedIndex (0 );
389
399
m_ControlsInCollectionBoxList->ClearList ();
390
400
391
401
// Clear focused control of the manager itself so it doesn't persist between selection changes (e.g property page line remains selected after clearing or changing selection)
0 commit comments