Skip to content

Commit

Permalink
#5568: Select the current image file path in the tree when opening th…
Browse files Browse the repository at this point in the history
…e dialog.
  • Loading branch information
codereader committed Mar 23, 2021
1 parent 8b0ada5 commit 211f30c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion radiant/ui/common/ImageFileSelector.cpp
Expand Up @@ -36,10 +36,15 @@ ImageFileSelector::ImageFileSelector(wxWindow* parent, wxTextCtrl* targetControl
FitToScreen(0.5f, 0.7f);
}

int ImageFileSelector::ShowModal()
int ImageFileSelector::ShowModal(const std::string& preselectItem)
{
_treeView->Populate(std::make_shared<ImageFilePopulator>(_columns));

if (!preselectItem.empty())
{
_treeView->SetSelectedFullname(preselectItem);
}

_previousValue = _targetControl->GetValue().ToStdString();

auto result = DialogBase::ShowModal();
Expand All @@ -53,6 +58,11 @@ int ImageFileSelector::ShowModal()
return result;
}

int ImageFileSelector::ShowModal()
{
return ShowModal(std::string());
}

std::string ImageFileSelector::GetSelectedImageFilePath()
{
auto item = _treeView->GetSelection();
Expand Down
1 change: 1 addition & 0 deletions radiant/ui/common/ImageFileSelector.h
Expand Up @@ -26,6 +26,7 @@ class ImageFileSelector :
ImageFileSelector(wxWindow* parent, wxTextCtrl* targetControl);

int ShowModal() override;
int ShowModal(const std::string& preselectItem);

// Returns the path of the selected image file
std::string GetSelectedImageFilePath();
Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/materials/MapExpressionEntry.h
Expand Up @@ -60,7 +60,7 @@ class MapExpressionEntry :
selector->SetSize(_windowToPlaceDialogsOn->GetSize());
}

selector->ShowModal();
selector->ShowModal(_textEntry->GetValue().ToStdString());
selector->Destroy();
}
};
Expand Down

0 comments on commit 211f30c

Please sign in to comment.