diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp
index bbef9dcc55..813020ffe0 100644
--- a/pcbnew/dialogs/dialog_drc.cpp
+++ b/pcbnew/dialogs/dialog_drc.cpp
@@ -75,27 +75,6 @@ DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* aEditorFra
InitValues();
- // Connect events
- m_ClearanceListBox->Connect( ID_CLEARANCE_LIST, wxEVT_LEFT_DCLICK,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnLeftDClickClearance ),
- NULL, this );
- m_ClearanceListBox->Connect( ID_CLEARANCE_LIST, wxEVT_RIGHT_UP,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnRightUpClearance ),
- NULL, this );
- m_UnconnectedListBox->Connect( ID_UNCONNECTED_LIST, wxEVT_LEFT_DCLICK,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnLeftDClickUnconnected ),
- NULL, this );
- m_UnconnectedListBox->Connect( ID_UNCONNECTED_LIST, wxEVT_RIGHT_UP,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnRightUpUnconnected ),
- NULL, this );
- m_FootprintsListBox->Connect( ID_FOOTPRINTS_LIST, wxEVT_LEFT_DCLICK,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnLeftDClickFootprints ),
- NULL, this );
- m_FootprintsListBox->Connect( ID_FOOTPRINTS_LIST, wxEVT_RIGHT_UP,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnRightUpFootprints ),
- NULL, this );
-
- // Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
}
@@ -105,26 +84,6 @@ DIALOG_DRC_CONTROL::~DIALOG_DRC_CONTROL()
m_config->Write( DrcRefillZonesKey, m_cbRefillZones->GetValue() );
m_config->Write( DrcTrackToZoneTestKey, m_cbReportTracksToZonesErrors->GetValue() );
m_config->Write( DrcTestFootprintsKey, m_cbTestFootprints->GetValue() );
-
- // Disconnect events
- m_ClearanceListBox->Disconnect( ID_CLEARANCE_LIST, wxEVT_LEFT_DCLICK,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnLeftDClickClearance ),
- NULL, this );
- m_ClearanceListBox->Disconnect( ID_CLEARANCE_LIST, wxEVT_RIGHT_UP,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnRightUpClearance ),
- NULL, this );
- m_UnconnectedListBox->Disconnect( ID_UNCONNECTED_LIST, wxEVT_LEFT_DCLICK,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnLeftDClickUnconnected ),
- NULL, this );
- m_UnconnectedListBox->Disconnect( ID_UNCONNECTED_LIST, wxEVT_RIGHT_UP,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnRightUpUnconnected ),
- NULL, this );
- m_FootprintsListBox->Disconnect( ID_FOOTPRINTS_LIST, wxEVT_LEFT_DCLICK,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnLeftDClickFootprints ),
- NULL, this );
- m_FootprintsListBox->Disconnect( ID_FOOTPRINTS_LIST, wxEVT_RIGHT_UP,
- wxMouseEventHandler( DIALOG_DRC_CONTROL::OnRightUpFootprints ),
- NULL, this );
}
@@ -337,14 +296,7 @@ void DIALOG_DRC_CONTROL::OnLeftDClickClearance( wxMouseEvent& event )
void DIALOG_DRC_CONTROL::OnRightUpFootprints( wxMouseEvent& event )
{
- // popup menu to go to either of the items listed in the DRC_ITEM.
- // Check if user right-clicked on a different item
- int selection = m_FootprintsListBox->HitTest( event.GetPosition() );
-
- if( selection == wxNOT_FOUND )
- selection = m_FootprintsListBox->GetSelection();
- else
- m_FootprintsListBox->SetSelection( selection );
+ int selection = rightUpClicSelection( m_FootprintsListBox, event );
if( selection != wxNOT_FOUND )
doSelectionMenu( m_FootprintsListBox->GetItem( selection ) );
@@ -384,16 +336,33 @@ bool DIALOG_DRC_CONTROL::focusOnItem( const DRC_ITEM* aItem )
}
+int DIALOG_DRC_CONTROL::rightUpClicSelection( DRCLISTBOX* aListBox, wxMouseEvent& event )
+{
+#if wxCHECK_VERSION( 3, 1, 3 )
+ // wxWidgets 3.1.3 has a bug in HitTest(): one cannot have the item selection
+ // on a right click: the returned value is always 10 so do not try to select
+ // an item on the right click. Just use the current selection (if any)
+ int selection = aListBox->GetSelection();
+#else
+ // Check if user right-clicked on a different item, and select the right clicked item
+ int selection = aListBox->HitTest( event.GetPosition() );
+
+ if( selection >= (int)aListBox->GetItemCount() ) // Should not happen.
+ selection = wxNOT_FOUND;
+#endif
+ if( selection == wxNOT_FOUND )
+ selection = aListBox->GetSelection();
+ else if( aListBox->GetSelection() != selection )
+ aListBox->SetSelection( selection );
+
+ return selection;
+}
+
+
void DIALOG_DRC_CONTROL::OnRightUpUnconnected( wxMouseEvent& event )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
- // Check if user right-clicked on a different item
- int selection = m_UnconnectedListBox->HitTest( event.GetPosition() );
-
- if( selection == wxNOT_FOUND )
- selection = m_UnconnectedListBox->GetSelection();
- else
- m_UnconnectedListBox->SetSelection( selection );
+ int selection = rightUpClicSelection( m_UnconnectedListBox, event );
if( selection != wxNOT_FOUND )
doSelectionMenu( m_UnconnectedListBox->GetItem( selection ) );
@@ -403,13 +372,7 @@ void DIALOG_DRC_CONTROL::OnRightUpUnconnected( wxMouseEvent& event )
void DIALOG_DRC_CONTROL::OnRightUpClearance( wxMouseEvent& event )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
- // Check if user right-clicked on a different item
- int selection = m_ClearanceListBox->HitTest( event.GetPosition() );
-
- if( selection == wxNOT_FOUND )
- selection = m_ClearanceListBox->GetSelection();
- else
- m_ClearanceListBox->SetSelection( selection );
+ int selection = rightUpClicSelection( m_ClearanceListBox, event );
if( selection != wxNOT_FOUND )
doSelectionMenu( m_ClearanceListBox->GetItem( selection ) );
diff --git a/pcbnew/dialogs/dialog_drc.h b/pcbnew/dialogs/dialog_drc.h
index c1dbc4d38b..2291c2c60d 100644
--- a/pcbnew/dialogs/dialog_drc.h
+++ b/pcbnew/dialogs/dialog_drc.h
@@ -3,7 +3,7 @@
*
* Copyright (C) 2011 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2009 Dick Hollenbeck, dick@softplc.com
- * Copyright (C) 2004-2012 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -92,6 +92,10 @@ private:
void SetDRCParameters( );
+ /// @return the selection on a right click on a DRCLISTBOX
+ /// return wxNOT_FOUND if no selection
+ int rightUpClicSelection( DRCLISTBOX* aListBox, wxMouseEvent& event );
+
/// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX_RPT_FILE
void OnReportCheckBoxClicked( wxCommandEvent& event ) override;
diff --git a/pcbnew/dialogs/dialog_drc_base.cpp b/pcbnew/dialogs/dialog_drc_base.cpp
index 1b48992ecb..e12fa1158e 100644
--- a/pcbnew/dialogs/dialog_drc_base.cpp
+++ b/pcbnew/dialogs/dialog_drc_base.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Oct 26 2018)
+// C++ code generated with wxFormBuilder (version Jul 10 2019)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -150,7 +150,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
m_ClearanceListBox = new DRCLISTBOX( m_panelViolations, ID_CLEARANCE_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_ClearanceListBox->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
- m_ClearanceListBox->SetToolTip( _("Left-click to center on problem marker. Right-click to highlight items.") );
+ m_ClearanceListBox->SetToolTip( _("Left-click to center on problem marker. \nRight-click to highlight items.") );
bSizerViolationsBox->Add( m_ClearanceListBox, 1, wxEXPAND|wxALL, 5 );
@@ -158,13 +158,13 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
m_panelViolations->SetSizer( bSizerViolationsBox );
m_panelViolations->Layout();
bSizerViolationsBox->Fit( m_panelViolations );
- m_Notebook->AddPage( m_panelViolations, _("Violations / Markers (%d)"), true );
+ m_Notebook->AddPage( m_panelViolations, _("Violations / Markers (%d)"), false );
m_panelUnconnectedItems = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerUnconnectedBox;
bSizerUnconnectedBox = new wxBoxSizer( wxVERTICAL );
m_UnconnectedListBox = new DRCLISTBOX( m_panelUnconnectedItems, ID_UNCONNECTED_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
- m_UnconnectedListBox->SetToolTip( _("Left-click to center on unconnected pair. Right-click to highlight unconnected items.") );
+ m_UnconnectedListBox->SetToolTip( _("Left-click to center on unconnected pair. \nRight-click to highlight unconnected items.") );
bSizerUnconnectedBox->Add( m_UnconnectedListBox, 1, wxALL|wxEXPAND, 5 );
@@ -172,7 +172,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
m_panelUnconnectedItems->SetSizer( bSizerUnconnectedBox );
m_panelUnconnectedItems->Layout();
bSizerUnconnectedBox->Fit( m_panelUnconnectedItems );
- m_Notebook->AddPage( m_panelUnconnectedItems, _("Unconnected Items (%d)"), false );
+ m_Notebook->AddPage( m_panelUnconnectedItems, _("Unconnected Items (%d)"), true );
m_panelFootprintWarnings = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerFootprintsBox;
bSizerFootprintsBox = new wxBoxSizer( wxVERTICAL );
diff --git a/pcbnew/dialogs/dialog_drc_base.fbp b/pcbnew/dialogs/dialog_drc_base.fbp
index 0bc3bdb061..a72a45e38d 100644
--- a/pcbnew/dialogs/dialog_drc_base.fbp
+++ b/pcbnew/dialogs/dialog_drc_base.fbp
@@ -14,6 +14,7 @@
dialog_drc_base
1000
none
+
1
dialog_drc_base
@@ -25,6 +26,7 @@
1
1
UI
+ 0
0
0