Fix focus stealing from wxDataViewCtrl

This commit is contained in:
Marek Roszko 2021-07-05 13:44:52 -04:00
parent 84092ce6d4
commit 12305990bb
1 changed files with 23 additions and 7 deletions

View File

@ -172,13 +172,29 @@ bool KIUI::IsInputControlFocused()
{
wxWindow* focus = wxWindow::FindFocus();
if( !focus )
{
return false;
}
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( focus );
wxStyledTextCtrl* styledText = dynamic_cast<wxStyledTextCtrl*>( focus );
wxListBox* listBox = dynamic_cast<wxListBox*>( focus );
wxDataViewCtrl* dataViewCtrl = dynamic_cast<wxDataViewCtrl*>( focus );
wxSearchCtrl* searchCtrl = dynamic_cast<wxSearchCtrl*>( focus );
return ( textEntry || styledText || listBox || dataViewCtrl || searchCtrl );
// Data view control is annoying, the focus is on a "wxDataViewCtrlMainWindow"
// class that is not formerly exported via the header.
// However, we can test the parent is wxDataViewCtrl instead
wxDataViewCtrl* dataViewCtrl = nullptr;
wxWindow* parent = focus->GetParent();
if( parent )
{
dataViewCtrl = dynamic_cast<wxDataViewCtrl*>( parent );
}
return ( textEntry || styledText || listBox || dataViewCtrl || searchCtrl || dataViewCtrl );
}