diff --git a/src/Spec2-Code-Morphic/SpMorphicCodeAdapter.class.st b/src/Spec2-Code-Morphic/SpMorphicCodeAdapter.class.st index 5b6d8fdf6..1a67464d0 100644 --- a/src/Spec2-Code-Morphic/SpMorphicCodeAdapter.class.st +++ b/src/Spec2-Code-Morphic/SpMorphicCodeAdapter.class.st @@ -62,10 +62,11 @@ SpMorphicCodeAdapter >> changeLineNumbers: hasLineNumbers to: aMorph [ { #category : #'private - shout' } SpMorphicCodeAdapter >> classOrMetaClass: aClass [ - self - setEditingModeFor: self widget textArea - withBehavior: aClass - forScripting: self isForScripting + self suspendObservedPropertiesWhile: [ + self + setEditingModeFor: self widget textArea + withBehavior: aClass + forScripting: self isForScripting ] ] { #category : #private } @@ -203,10 +204,11 @@ SpMorphicCodeAdapter >> setEditingModeFor: textArea [ self hasSyntaxHighlight ifTrue: [ - self - setEditingModeFor: textArea - withBehavior: self behavior - forScripting: self isForScripting ] + self suspendObservedPropertiesWhile: [ + self + setEditingModeFor: textArea + withBehavior: self behavior + forScripting: self isForScripting ] ] ifFalse: [ super setEditingModeFor: textArea ] ] @@ -247,6 +249,17 @@ SpMorphicCodeAdapter >> setSyntaxHighlightThemeFor: textArea [ refreshStyling ] +{ #category : #private } +SpMorphicCodeAdapter >> suspendObservedPropertiesWhile: aBlock [ + | textHolder textSubscriptions | + + textHolder := self presenter observablePropertyNamed: #text. + textSubscriptions := textHolder subscriptions. + textHolder subscriptions: #(). + aBlock ensure: [ + textHolder subscriptions: textSubscriptions ] +] + { #category : #private } SpMorphicCodeAdapter >> textWithStyle [ "This method is to be used for testing. diff --git a/src/Spec2-Code-Tests/SpCodePresenterTest.class.st b/src/Spec2-Code-Tests/SpCodePresenterTest.class.st index 4d8508b0b..0857b3b3f 100644 --- a/src/Spec2-Code-Tests/SpCodePresenterTest.class.st +++ b/src/Spec2-Code-Tests/SpCodePresenterTest.class.st @@ -41,6 +41,16 @@ SpCodePresenterTest >> newEnvironment [ ^ environment ] +{ #category : #tests } +SpCodePresenterTest >> testChangingEditingModeDoesNotTriggersTextChanged [ + | changed | + + changed := false. + presenter whenTextChangedDo: [ changed := true ]. + presenter beForBehavior: Object. + self deny: changed +] + { #category : #tests } SpCodePresenterTest >> testContextKeyBindings [ | contextKeyBindings | diff --git a/src/Spec2-Core/SpListPresenter.class.st b/src/Spec2-Core/SpListPresenter.class.st index 3aa5f5781..d74334dbd 100644 --- a/src/Spec2-Core/SpListPresenter.class.st +++ b/src/Spec2-Core/SpListPresenter.class.st @@ -143,27 +143,6 @@ SpListPresenter >> iconFor: anItem [ cull: self ] -{ #category : #api } -SpListPresenter >> icons [ - "Return the block used to return an icon that will be displayed in the list" - self - deprecated: 'Use #displayIcon' - transformWith: '`@receiver icons' -> '`@receiver displayIcon'. - - ^ icon -] - -{ #category : #api } -SpListPresenter >> icons: aBlock [ - "Set a block which takes an item as argument and returns the icon to display in the list. - `aBlock` receives one argument" - self - deprecated: 'Use #displayIcon:' - transformWith: '`@receiver icons: `@arg' -> '`@receiver displayIcon: `@arg'. - - icon := aBlock -] - { #category : #initialization } SpListPresenter >> initialize [ diff --git a/src/Spec2-Core/SpTPresenterBuilder.trait.st b/src/Spec2-Core/SpTPresenterBuilder.trait.st index a61c86a13..1efdb985f 100644 --- a/src/Spec2-Core/SpTPresenterBuilder.trait.st +++ b/src/Spec2-Core/SpTPresenterBuilder.trait.st @@ -105,6 +105,11 @@ SpTPresenterBuilder >> newGridLayout [ ^ SpGridLayout new ] +{ #category : #'scripting - widgets' } +SpTPresenterBuilder >> newImage [ + ^ self instantiate: SpImagePresenter +] + { #category : #'scripting - widgets' } SpTPresenterBuilder >> newLabel [ ^ self instantiate: SpLabelPresenter diff --git a/src/Spec2-Core/SpTextInputFieldPresenter.class.st b/src/Spec2-Core/SpTextInputFieldPresenter.class.st index 48b9241cf..98f6a9cf6 100644 --- a/src/Spec2-Core/SpTextInputFieldPresenter.class.st +++ b/src/Spec2-Core/SpTextInputFieldPresenter.class.st @@ -203,6 +203,6 @@ SpTextInputFieldPresenter >> whenSubmitDo: aBlock [ `aBlock` receives one argument (the submited text)" self - bindKeyCombination: Character cr asKeyCombination | $s meta + bindKeyCombination: SpAcceptChangesCommand defaultShortcutKey | Character cr asKeyCombination toAction: aBlock ] diff --git a/src/Spec2-Morphic/SpTPresenterBuilder.extension.st b/src/Spec2-Morphic/SpTPresenterBuilder.extension.st index 46acc21a6..6e48ed5c0 100644 --- a/src/Spec2-Morphic/SpTPresenterBuilder.extension.st +++ b/src/Spec2-Morphic/SpTPresenterBuilder.extension.st @@ -1,10 +1,5 @@ Extension { #name : #SpTPresenterBuilder } -{ #category : #'*Spec2-Morphic' } -SpTPresenterBuilder >> newImage [ - ^ self instantiate: SpImagePresenter -] - { #category : #'*Spec2-Morphic' } SpTPresenterBuilder >> newLink [ ^ self instantiate: SpLinkPresenter