Schematic: don't require cursor on selected net to assign netclass

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13199
This commit is contained in:
Mike Williams 2022-12-22 10:15:48 -05:00
parent bf5fd38bf7
commit 3037f2b444
1 changed files with 99 additions and 86 deletions

View File

@ -1187,14 +1187,28 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
m_frame->RecalculateConnections( NO_CLEANUP );
}
// Remove selection in favor of highlighting so the whole net is highlighted
selectionTool->ClearSelection();
highlightNet( m_toolMgr, cursorPos );
const SCH_CONNECTION* conn = nullptr;
VECTOR2D connPos;
const SCH_CONNECTION* conn = m_frame->GetHighlightedConnection();
for( EDA_ITEM* item : selectionTool->GetSelection() )
{
conn = static_cast<SCH_ITEM*>( item )->Connection();
connPos = item->GetPosition();
if( conn )
break;
}
if( !conn )
{
m_frame->ShowInfoBarError( _( "No net selected." ) );
return 0;
}
// Remove selection in favor of highlighting so the whole net is highlighted
selectionTool->ClearSelection();
highlightNet( m_toolMgr, connPos );
wxString netName = conn->Name();
if( conn->IsBus() )
@ -1304,7 +1318,6 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
return 0;
} );
}
}
highlightNet( m_toolMgr, CLEAR );
return 0;