From ad0dc0134fafceb547820a32902f5ae1c42fe99e Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Wed, 10 Apr 2024 15:25:36 +0200 Subject: [PATCH 1/2] set default button as default in morphic side :) --- .../SpMorphicButtonAdapter.class.st | 6 ++++++ .../SpMorphicDialogWindowAdapter.class.st | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicButtonAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicButtonAdapter.class.st index 1da4e139..f74e4456 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicButtonAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicButtonAdapter.class.st @@ -175,6 +175,12 @@ SpMorphicButtonAdapter >> newButton [ menu: #menu: ] +{ #category : 'accessing' } +SpMorphicButtonAdapter >> setAsDefault [ + + self widget isDefault: true +] + { #category : 'factory' } SpMorphicButtonAdapter >> setWidgetColor: button [ diff --git a/src/Spec2-Adapters-Morphic/SpMorphicDialogWindowAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicDialogWindowAdapter.class.st index ed23de72..beb3a0cd 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicDialogWindowAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicDialogWindowAdapter.class.st @@ -16,16 +16,18 @@ SpMorphicDialogWindowAdapter >> addPresenterIn: widgetToBuild withSpecLayout: aS super addPresenterIn: widgetToBuild withSpecLayout: aSpec. self model buttons ifNotEmpty: [ - widgetToBuild setToolbarFrom: [ self buildButtonBar ] ] + widgetToBuild setToolbarFrom: [ self buildButtonBar ]. + self presenter defaultButton + ifNotNil: [ :aButton | aButton adapter setAsDefault ] ] ] { #category : 'factory' } SpMorphicDialogWindowAdapter >> buildButtonBar [ - | buttonBar | + buttonBar := (SpButtonBarPresenter owner: self model) placeAtEnd. - self model buttons do: [ :buttonPresenter | - buttonBar add: buttonPresenter ]. + self model buttons + do: [ :buttonPresenter | buttonBar add: buttonPresenter ]. ^ buttonBar ] From ce7e32ad06d1095e1cae2a3463f535db89db1a5b Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Wed, 10 Apr 2024 15:36:21 +0200 Subject: [PATCH 2/2] do not override ok/cancel actions unless they are actually defined --- src/Spec2-Dialogs/SpDialogPresenter.class.st | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Spec2-Dialogs/SpDialogPresenter.class.st b/src/Spec2-Dialogs/SpDialogPresenter.class.st index 37f8b570..0965adab 100644 --- a/src/Spec2-Dialogs/SpDialogPresenter.class.st +++ b/src/Spec2-Dialogs/SpDialogPresenter.class.st @@ -154,10 +154,9 @@ SpDialogPresenter >> icon: aForm [ { #category : 'initialization' } SpDialogPresenter >> initializeDialogWindow: aDialogWindowPresenter [ - - aDialogWindowPresenter - okAction: acceptAction; - cancelAction: cancelAction. + + acceptAction ifNotNil: [ aDialogWindowPresenter okAction: acceptAction ]. + cancelAction ifNotNil: [ aDialogWindowPresenter cancelAction: cancelAction ]. self parentWindow ifNotNil: [ :w | aDialogWindowPresenter centeredRelativeTo: w ]