Skip to content

Commit

Permalink
Delete without confirmation using Shift instead of Ctrl
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Oct 31, 2024
1 parent c77ac8d commit 81aa242
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions repository/OpenPonk-Spec/OPDiagramRemoveFigureCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ OPDiagramRemoveFigureCommand class >> canvasShortcutActivation [
(KeyboardKey new withValue: 16rffff andName: #delete)).
((KMSingleKeyCombination new key:
(KeyboardKey new withValue: 16rffff andName: #delete))
modifiedBy: KMModifier meta) })
modifiedBy: self skipConfirmationModifier) })
for: OPCanvasPresenter
]

{ #category : 'accessing' }
OPDiagramRemoveFigureCommand class >> lastEvent [

self flag:
'Part of ugly hack to find out if ctrl is currently pressed'.
'Part of ugly hack to find out if the modifier key was pressed'.

^ lastEvent
]
Expand All @@ -40,11 +40,17 @@ OPDiagramRemoveFigureCommand class >> lastEvent [
OPDiagramRemoveFigureCommand class >> lastEvent: anEvent [

self flag:
'Part of ugly hack to find out if ctrl is currently pressed'.
'Part of ugly hack to find out if the modifier key was pressed'.

lastEvent := anEvent
]

{ #category : 'constants' }
OPDiagramRemoveFigureCommand class >> skipConfirmationModifier [

^ KMModifier shift
]

{ #category : 'accessing' }
OPDiagramRemoveFigureCommand >> defaultMenuIcon [
^ self iconNamed: #glamorousTrash
Expand Down Expand Up @@ -72,32 +78,30 @@ OPDiagramRemoveFigureCommand >> doAndReturnFocus: aBlock [
{ #category : 'execution' }
OPDiagramRemoveFigureCommand >> execute [

| lastEvent |
lastEvent := self class lastEvent.
(lastEvent isNotNil and: [
lastEvent controlKeyPressed or: [ lastEvent commandKeyPressed ] ])
ifTrue: [ self unsafeExecute ]
ifFalse: [ self safeExecute ]
self class lastEvent ifNotNil: [ :lastEvent |
(self class skipConfirmationModifier matchesEvent: lastEvent)
ifTrue: [ ^ self executeWithoutConfirmation ] ].
self executeWithConfirmation
]

{ #category : 'execution' }
OPDiagramRemoveFigureCommand >> safeExecute [
OPDiagramRemoveFigureCommand >> executeWithConfirmation [

| result |
result := self doAndReturnFocus: [
UIManager default
proceed:
'Permanently remove from model? (to skip this confirmation, hold '
, OSPlatform current defaultModifier name
, self class skipConfirmationModifier name
, ' next time)'
title: 'Remove?' ].
result ifNil: [ ^ self ].
result ifFalse: [ ^ self ].
self unsafeExecute
self executeWithoutConfirmation
]

{ #category : 'execution' }
OPDiagramRemoveFigureCommand >> unsafeExecute [
OPDiagramRemoveFigureCommand >> executeWithoutConfirmation [

diagramController deselectAll.
figures do: [ :each |
Expand Down

0 comments on commit 81aa242

Please sign in to comment.