Confirm when cancelling a changed custom rule

This commit is contained in:
Seth Hillbrand 2021-01-26 08:18:35 -08:00
parent 1e9639e89c
commit 9a51a75403
2 changed files with 18 additions and 0 deletions

View File

@ -22,6 +22,7 @@
*/
#include <bitmaps.h>
#include <confirm.h>
#include <widgets/paged_dialog.h>
#include <pcb_edit_frame.h>
#include <pcb_expr_evaluator.h>
@ -60,6 +61,7 @@ PANEL_SETUP_RULES::PANEL_SETUP_RULES( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFr
m_textEditor->Bind( wxEVT_STC_CHARADDED, &PANEL_SETUP_RULES::onScintillaCharAdded, this );
m_textEditor->Bind( wxEVT_STC_AUTOCOMP_CHAR_DELETED, &PANEL_SETUP_RULES::onScintillaCharAdded, this );
m_textEditor->Bind( wxEVT_CHAR_HOOK, &PANEL_SETUP_RULES::onCharHook, this );
}
@ -72,6 +74,21 @@ PANEL_SETUP_RULES::~PANEL_SETUP_RULES( )
};
void PANEL_SETUP_RULES::onCharHook( wxKeyEvent& aEvent )
{
if( aEvent.GetKeyCode() == WXK_ESCAPE && !m_textEditor->AutoCompActive() )
{
if( m_originalText != m_textEditor->GetText() )
{
if( !IsOK( this, _( "Cancel Changes?" ) ) )
return;
}
}
aEvent.Skip();
}
void PANEL_SETUP_RULES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
{
m_Parent->SetModified();

View File

@ -58,6 +58,7 @@ private:
void OnSyntaxHelp( wxHyperlinkEvent& aEvent ) override;
void OnCompile( wxCommandEvent& event ) override;
void OnErrorLinkClicked( wxHtmlLinkEvent& event ) override;
void onCharHook( wxKeyEvent& aEvent );
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;