Schematic/PCB: deleting fields sets them to invisible

This commit is contained in:
Mike Williams 2022-04-11 14:03:17 -04:00 committed by Roberto Fernandez Bautista
parent 1e80f3a65a
commit b42365190e
2 changed files with 21 additions and 21 deletions

View File

@ -1028,6 +1028,7 @@ static KICAD_T deletableItems[] =
SCH_SHEET_T, SCH_SHEET_T,
SCH_SHEET_PIN_T, SCH_SHEET_PIN_T,
SCH_SYMBOL_T, SCH_SYMBOL_T,
SCH_FIELD_T, // Will be hidden
SCH_BITMAP_T, SCH_BITMAP_T,
EOT EOT
}; };
@ -1083,6 +1084,14 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
sheet->RemovePin( pin ); sheet->RemovePin( pin );
} }
} }
else if( sch_item->Type() == SCH_FIELD_T )
{
saveCopyInUndoList( item, UNDO_REDO::CHANGED, appendToUndo );
static_cast<SCH_FIELD*>( sch_item )->SetVisible( false );
appendToUndo = true;
updateItem( sch_item, false );
}
else else
{ {
sch_item->SetFlags( STRUCT_DELETED ); sch_item->SetFlags( STRUCT_DELETED );

View File

@ -1843,32 +1843,23 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
FP_TEXT* text = static_cast<FP_TEXT*>( item ); FP_TEXT* text = static_cast<FP_TEXT*>( item );
FOOTPRINT* parent = static_cast<FOOTPRINT*>( item->GetParent() ); FOOTPRINT* parent = static_cast<FOOTPRINT*>( item->GetParent() );
if( text->GetType() == FP_TEXT::TEXT_is_DIVERS ) switch( text->GetType() )
{ {
case FP_TEXT::TEXT_is_VALUE:
case FP_TEXT::TEXT_is_REFERENCE:
m_commit->Modify( parent );
text->SetVisible( false );
getView()->Update( text );
break;
case FP_TEXT::TEXT_is_DIVERS:
m_commit->Modify( parent ); m_commit->Modify( parent );
getView()->Remove( text ); getView()->Remove( text );
parent->Remove( text ); parent->Remove( text );
}
else if( selectionCopy.GetSize() == 1 )
{
text->SetVisible( false );
getView()->Update( text );
switch( text->GetType() )
{
case FP_TEXT::TEXT_is_REFERENCE:
frame()->ShowInfoBarMsg( _( "Reference designator hidden (it is required and "
"can not be deleted)." ) );
break;
case FP_TEXT::TEXT_is_VALUE:
frame()->ShowInfoBarMsg( _( "Value hidden (it is required and can not be "
"deleted)." ) );
break; break;
default: default:
wxFAIL; // Shouldn't get here wxFAIL; // Shouldn't get here
break; break;
} }
}
break; break;
} }