Skip to content

Commit

Permalink
now sorting names, added hotkey, fixed focus. fix #5270
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 18, 2019
1 parent cc0ce14 commit 68a3d7d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/utils/gui/windows/GUIDialog_GLObjChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ GUIDialog_GLObjChooser::GUIDialog_GLObjChooser(GUIGlChildWindow* parent, FXIcon*
new FXHorizontalSeparator(layoutRight, GUIDesignHorizontalSeparator);
new FXButton(layoutRight, "&Hide Unselected\t\t", GUIIconSubSys::getIcon(ICON_FLAG), this, MID_CHOOSER_FILTER, GUIDesignChooserButtons);
new FXButton(layoutRight, "&Select/deselect\tSelect/deselect current object\t", GUIIconSubSys::getIcon(ICON_FLAG), this, MID_CHOOSEN_INVERT, GUIDesignChooserButtons);
new FXButton(layoutRight, "By Name\tLocate item by name\t", nullptr, this, MID_CHOOSEN_NAME, GUIDesignChooserButtons);
new FXButton(layoutRight, "By &Name\tLocate item by name\t", nullptr, this, MID_CHOOSEN_NAME, GUIDesignChooserButtons);
new FXHorizontalSeparator(layoutRight, GUIDesignHorizontalSeparator);
new FXButton(layoutRight, "&Close\t\t", GUIIconSubSys::getIcon(ICON_NO), this, MID_CANCEL, GUIDesignChooserButtons);

Expand Down Expand Up @@ -262,19 +262,25 @@ GUIDialog_GLObjChooser::onCmdToggleSelection(FXObject*, FXSelector, void*) {

long
GUIDialog_GLObjChooser::onCmdLocateByName(FXObject*, FXSelector, void*) {
std::vector<GUIGlID> selectedGlIDs;
std::vector<std::pair<std::string, GUIGlID> > namesAndIDs;
myLocateByName = true;
const int numItems = myList->getNumItems();
for (int i = 0; i < numItems; i++) {
GUIGlID glID = *static_cast<GUIGlID*>(myList->getItemData(i));
GUIGlObject* o = GUIGlObjectStorage::gIDStorage.getObjectBlocking(glID);
const std::string& name = getObjectName(o);
if (name != "") {
selectedGlIDs.push_back(glID);
namesAndIDs.push_back(std::make_pair(name, glID));
}
GUIGlObjectStorage::gIDStorage.unblockObject(glID);
}
std::sort(namesAndIDs.begin(), namesAndIDs.end());
std::vector<GUIGlID> selectedGlIDs;
for (const auto& item : namesAndIDs) {
selectedGlIDs.push_back(item.second);
}
refreshList(selectedGlIDs);
myTextEntry->setFocus();
return 1;
}

Expand Down

0 comments on commit 68a3d7d

Please sign in to comment.