From 18c2f271f330e3765d031c0f4255456a31dd0094 Mon Sep 17 00:00:00 2001 From: Jan Bliznicenko Date: Tue, 10 Oct 2023 15:20:41 +0200 Subject: [PATCH] improved creation feedback behavior --- .../OpenPonk-Core/OPEditElementTextCommand.class.st | 4 +++- .../OpenPonk-Core/OPRenameElementCommand.class.st | 7 +++++-- repository/OpenPonk-Core/OPUICommand.class.st | 11 +++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/repository/OpenPonk-Core/OPEditElementTextCommand.class.st b/repository/OpenPonk-Core/OPEditElementTextCommand.class.st index 2c30b5b8..8264d9c0 100644 --- a/repository/OpenPonk-Core/OPEditElementTextCommand.class.st +++ b/repository/OpenPonk-Core/OPEditElementTextCommand.class.st @@ -40,8 +40,10 @@ OPEditElementTextCommand >> announceChange [ { #category : #execute } OPEditElementTextCommand >> execute [ + | result | - result := UIManager default request: name initialAnswer: get value. + result := self doAndReturnFocus: [ + UIManager default request: name initialAnswer: get value ]. result ifNil: [ ^ self ]. set value: result. self announceChange diff --git a/repository/OpenPonk-Core/OPRenameElementCommand.class.st b/repository/OpenPonk-Core/OPRenameElementCommand.class.st index a74fec77..5fcdc449 100644 --- a/repository/OpenPonk-Core/OPRenameElementCommand.class.st +++ b/repository/OpenPonk-Core/OPRenameElementCommand.class.st @@ -25,9 +25,12 @@ Class { OPRenameElementCommand >> execute [ | result | - result := UIManager default request: 'Enter a name' initialAnswer: (controller model name). + result := self doAndReturnFocus: [ + UIManager default + request: 'Enter a name' + initialAnswer: controller model name ]. result ifNil: [ ^ self ]. result ifEmpty: [ ^ self ]. controller model name: result. - controller model announcer announce: OPElementRenamed new. + controller model announcer announce: OPElementRenamed new ] diff --git a/repository/OpenPonk-Core/OPUICommand.class.st b/repository/OpenPonk-Core/OPUICommand.class.st index 010bd24b..fa6f94b4 100644 --- a/repository/OpenPonk-Core/OPUICommand.class.st +++ b/repository/OpenPonk-Core/OPUICommand.class.st @@ -24,6 +24,17 @@ OPUICommand class >> on: anElementController [ yourself ] +{ #category : #utilities } +OPUICommand >> doAndReturnFocus: aBlock [ + + | result window wasActive | + window := controller diagramController canvasPresenter window window. + wasActive := window isActive. + result := aBlock value. + window activate. + ^ result +] + { #category : #execute } OPUICommand >> execute [ ^ self subclassResponsibility