7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 15:20:10 +00:00

Hack-fix for paste into std dialog search box.

It's hard to know how widely this fix needs to be
applied, but this should at least get most of the
cases.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19684
This commit is contained in:
Jeff Young 2025-01-20 12:57:22 +00:00
parent db877e6a00
commit 240a745aa7
3 changed files with 50 additions and 6 deletions

View File

@ -64,6 +64,18 @@ public:
m_win->Raise(); // let's focus back on the parent window
}
}
void Suspend()
{
if( m_win )
m_win->Enable();
}
void Resume()
{
if( m_win )
m_win->Disable();
}
};
@ -560,6 +572,20 @@ int DIALOG_SHIM::ShowQuasiModal()
}
void DIALOG_SHIM::PrepareForModalSubDialog()
{
if( m_qmodal_parent_disabler )
m_qmodal_parent_disabler->Suspend();
}
void DIALOG_SHIM::CleanupAfterModalSubDialog()
{
if( m_qmodal_parent_disabler )
m_qmodal_parent_disabler->Resume();
}
void DIALOG_SHIM::EndQuasiModal( int retCode )
{
// Hook up validator and transfer data from controls handling so quasi-modal dialogs

View File

@ -360,6 +360,8 @@ protected:
void OnButtonClick() override
{
m_dlg->PrepareForModalSubDialog();
wxString filename = GetValue();
if( filename.IsEmpty() || filename == wxT( "~" ) )
@ -389,6 +391,8 @@ protected:
{
GetAssociatedDocument( m_dlg, GetValue(), &m_dlg->Prj(), m_searchStack, m_files );
}
m_dlg->CleanupAfterModalSubDialog();
}
void OnTextChange(wxCommandEvent& event)
@ -405,8 +409,9 @@ protected:
SetButtonBitmaps( KiBitmapBundle( BITMAPS::www ) );
}
DIALOG_SHIM* m_dlg;
SEARCH_STACK* m_searchStack;
protected:
DIALOG_SHIM* m_dlg;
SEARCH_STACK* m_searchStack;
EMBEDDED_FILES* m_files;
};
@ -419,9 +424,7 @@ void GRID_CELL_URL_EDITOR::Create( wxWindow* aParent, wxWindowID aId, wxEvtHandl
#if wxUSE_VALIDATORS
// validate text in textctrl, if validator is set
if ( m_validator )
{
Combo()->SetValidator( *m_validator );
}
#endif
wxGridCellEditor::Create( aParent, aId, aEventHandler );
@ -479,6 +482,8 @@ protected:
void OnButtonClick() override
{
m_dlg->PrepareForModalSubDialog();
if( m_fileFilterFn )
m_fileFilter = m_fileFilterFn( m_grid, m_grid->GetGridCursorRow() );
@ -549,8 +554,11 @@ protected:
*m_currentDir = relPath;
}
}
m_dlg->CleanupAfterModalSubDialog();
}
protected:
DIALOG_SHIM* m_dlg;
WX_GRID* m_grid;
wxString* m_currentDir;
@ -566,21 +574,23 @@ void GRID_CELL_PATH_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
wxEvtHandler* aEventHandler )
{
if( m_fileFilterFn )
{
m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir,
m_fileFilterFn, m_normalize,
m_normalizeBasePath );
}
else
{
m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir,
m_fileFilter, m_normalize, m_normalizeBasePath );
}
WX_GRID::CellEditorSetMargins( Combo() );
#if wxUSE_VALIDATORS
// validate text in textctrl, if validator is set
if ( m_validator )
{
Combo()->SetValidator( *m_validator );
}
#endif
wxGridCellEditor::Create( aParent, aId, aEventHandler );

View File

@ -112,6 +112,14 @@ public:
bool IsQuasiModal() const { return m_qmodal_showing; }
// A quasi-modal dialog disables its parent window. Sadly this disabling is more extreme
// than wxWidgets' normal modal dialog disabling, and prevents things like hotkey Cut/Copy/
// Paste from working in search controls in standard file dialogs. So when we put up a modal
// dialog in front of a quasi-modal, we suspend the quasi-modal dialog parent window
// disabling, causing us to fall back to the normal modal dialog parent window disabling.
void PrepareForModalSubDialog();
void CleanupAfterModalSubDialog();
bool Show( bool show ) override;
bool Enable( bool enable ) override;