From 72e39fc865df999108f2bd71293c8517ffc5e241 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Fri, 22 Jul 2022 22:34:52 -0400 Subject: [PATCH] Get it working for SCH_TEXT with infobar error message --- eeschema/dialogs/dialog_text_properties.cpp | 4 +++- .../dialogs/dialog_text_properties_base.cpp | 4 ++-- .../dialogs/dialog_text_properties_base.fbp | 4 ++-- eeschema/sch_text.cpp | 22 +++++++++++++------ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index 09cbf17255..2cbb23e2f4 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -405,7 +405,9 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() if( !m_currentText->ValidateHyperlink( m_hyperlinkCtrl->GetValue() ) ) { - DisplayError( this, _( "Invalid hyperlink destination (URL)." ) ); + DisplayError( this, _( "Invalid hyperlink destination. Please enter either a valid URL " + "(e.g. file:// or http(s)://) or \"goto:\" to create " + "a hyperlink to a page in this schematic." ) ); return false; } else diff --git a/eeschema/dialogs/dialog_text_properties_base.cpp b/eeschema/dialogs/dialog_text_properties_base.cpp index 9a03a90747..64086321d9 100644 --- a/eeschema/dialogs/dialog_text_properties_base.cpp +++ b/eeschema/dialogs/dialog_text_properties_base.cpp @@ -92,7 +92,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi bSizer11->Add( 10, 0, 0, wxEXPAND, 5 ); - m_hyperlinkDestinationLabel = new wxStaticText( this, wxID_ANY, _("Destination (URL):"), wxDefaultPosition, wxDefaultSize, 0 ); + m_hyperlinkDestinationLabel = new wxStaticText( this, wxID_ANY, _("Destination:"), wxDefaultPosition, wxDefaultSize, 0 ); m_hyperlinkDestinationLabel->Wrap( -1 ); m_hyperlinkDestinationLabel->Enable( false ); @@ -100,7 +100,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi m_hyperlinkCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); m_hyperlinkCtrl->Enable( false ); - m_hyperlinkCtrl->SetToolTip( _("Please enter a file:// or http(s):// URL") ); + m_hyperlinkCtrl->SetToolTip( _("Please enter either a valid URL (e.g. file:// or http(s)://) or \"goto:\" to create a hyperlink to a page in this schematic.") ); bSizer11->Add( m_hyperlinkCtrl, 10, wxALL, 5 ); diff --git a/eeschema/dialogs/dialog_text_properties_base.fbp b/eeschema/dialogs/dialog_text_properties_base.fbp index 0b85592984..497912cdbf 100644 --- a/eeschema/dialogs/dialog_text_properties_base.fbp +++ b/eeschema/dialogs/dialog_text_properties_base.fbp @@ -468,7 +468,7 @@ 0 0 wxID_ANY - Destination (URL): + Destination: 0 0 @@ -550,7 +550,7 @@ 0 - Please enter a file:// or http(s):// URL + Please enter either a valid URL (e.g. file:// or http(s)://) or "goto:<page sequence>" to create a hyperlink to a page in this schematic. wxFILTER_NONE wxDefaultValidator diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index dcc2fb728a..1cdb99d011 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -408,15 +408,23 @@ void SCH_TEXT::DoHypertextMenu( EDA_DRAW_FRAME* aFrame ) const sheetNames[sheet.GetVirtualPageNumber()] = sheet.Last()->GetName(); } - menu.Append( 0, wxString::Format( _( "Go to Page %s (%s)" ), - sheetPages[destPage], - sheetNames[destPage] ) ); + if( sheetPages.count( destPage ) > 0 ) + { + menu.Append( 0, wxString::Format( _( "Go to Page %s (%s)" ), + sheetPages[destPage], + sheetNames[destPage] ) ); - int sel = aFrame->GetPopupMenuSelectionFromUser( menu ); - void* param = &sheetPages[destPage]; + int sel = aFrame->GetPopupMenuSelectionFromUser( menu ); + void* param = &sheetPages[destPage]; - if( param ) - aFrame->GetToolManager()->RunAction( EE_ACTIONS::hypertextCommand, true, param ); + if( param ) + aFrame->GetToolManager()->RunAction( EE_ACTIONS::hypertextCommand, true, param ); + } + else + { + aFrame->ShowInfoBarError( wxString::Format( _( "Page sequence '%d' does not exist." ), + destPage ) ); + } } else {