Skip to content

Commit

Permalink
Fix context menu for resources list box
Browse files Browse the repository at this point in the history
  • Loading branch information
seedhartha committed Nov 24, 2024
1 parent f703574 commit 700a748
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/apps/toolkit/view/resource/explorerframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void ResourceExplorerFrame::InitControls() {

m_resourcesListBox = new wxListBox(resourcesPanel, wxID_ANY);
m_resourcesListBox->Bind(wxEVT_CONTEXT_MENU, &ResourceExplorerFrame::OnResourcesListBoxContextMenu, this);
m_resourcesListBox->Bind(wxEVT_LISTBOX, &ResourceExplorerFrame::OnResourcesListBox, this);
m_resourcesListBox->Bind(wxEVT_LISTBOX_DCLICK, &ResourceExplorerFrame::OnResourcesListBoxDoubleClick, this);

auto navigationPanel = new wxPanel(resourcesPanel);
Expand Down Expand Up @@ -404,6 +405,10 @@ void ResourceExplorerFrame::OnGoToParentButton(wxCommandEvent &event) {
m_viewModel.onGoToParentButton();
}

void ResourceExplorerFrame::OnResourcesListBox(wxCommandEvent &event) {
_resListBoxSelection = event.GetSelection();
}

void ResourceExplorerFrame::OnResourcesListBoxDoubleClick(wxCommandEvent &event) {
int itemIdx = event.GetInt();
if (itemIdx == -1) {
Expand All @@ -417,12 +422,8 @@ void ResourceExplorerFrame::OnResourcesListBoxDoubleClick(wxCommandEvent &event)
m_viewModel.onResourcesListBoxDoubleClick(resItemId);
}

void ResourceExplorerFrame::OnResourcesListBoxContextMenu(wxCommandEvent &event) {
int itemIdx = event.GetInt();
if (itemIdx == -1) {
return;
}
auto *itemData = m_resourcesListBox->GetClientObject(itemIdx);
void ResourceExplorerFrame::OnResourcesListBoxContextMenu(wxContextMenuEvent &event) {
auto *itemData = m_resourcesListBox->GetClientObject(_resListBoxSelection);
if (!itemData) {
return;
}
Expand Down
4 changes: 3 additions & 1 deletion src/apps/toolkit/view/resource/explorerframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ResourceExplorerFrame : public wxFrame {

private:
ResourceExplorerViewModel &m_viewModel;
int _resListBoxSelection {0};

// Menus

Expand Down Expand Up @@ -96,8 +97,9 @@ class ResourceExplorerFrame : public wxFrame {
void OnComposeLipCommand(wxCommandEvent &event);
void OnGoToParentButton(wxCommandEvent &event);

void OnResourcesListBox(wxCommandEvent &event);
void OnResourcesListBoxContextMenu(wxContextMenuEvent &event);
void OnResourcesListBoxDoubleClick(wxCommandEvent &event);
void OnResourcesListBoxContextMenu(wxCommandEvent &event);

void OnNotebookPageClose(wxAuiNotebookEvent &event);
void OnNotebookPageChanged(wxAuiNotebookEvent &event);
Expand Down

0 comments on commit 700a748

Please sign in to comment.