Skip to content

Commit

Permalink
Auto-close the Choose Shader dialog when double-clicking a 'valued' t…
Browse files Browse the repository at this point in the history
…ree node
  • Loading branch information
duzenko committed Sep 11, 2021
1 parent 8b12f67 commit ef284b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/wxutil/dataview/TreeView.cpp
Expand Up @@ -257,6 +257,7 @@ void TreeView::_onItemActivated(wxDataViewEvent& ev)
if (!IsExpanded(ev.GetItem()))
{
Expand(ev.GetItem());
wxQueueEvent( GetParent()->GetEventHandler(), new wxCommandEvent( EV_TREE_DOUBLE_CLICK ) );
}
else
{
Expand Down Expand Up @@ -631,4 +632,5 @@ void TreeView::JumpToSearchMatch(const wxDataViewItem& item)
}
}

wxDEFINE_EVENT( EV_TREE_DOUBLE_CLICK, wxCommandEvent );
} // namespace
1 change: 1 addition & 0 deletions libs/wxutil/dataview/TreeView.h
Expand Up @@ -101,4 +101,5 @@ class TreeView :
void _onItemActivated(wxDataViewEvent& ev);
};

wxDECLARE_EVENT( EV_TREE_DOUBLE_CLICK, wxCommandEvent );
} // namespace
8 changes: 8 additions & 0 deletions radiant/ui/common/ShaderChooser.cpp
Expand Up @@ -38,6 +38,14 @@ ShaderChooser::ShaderChooser(wxWindow* parent, wxTextCtrl* targetEntry) :

// Set the cursor of the tree view to the currently selected shader
_selector->setSelection(_initialShader);
Bind( wxutil::EV_TREE_DOUBLE_CLICK, [&, this]( wxCommandEvent& ev )
{
if ( !this->_selector->getSelection().empty() ) {
_targetEntry->SetValue( _selector->getSelection() );
shutdown();
EndModal( wxID_OK );
}
} );
}

// Pack in the ShaderSelector and buttons panel
Expand Down

0 comments on commit ef284b9

Please sign in to comment.