From bee2443d975d4f04881bfd833f20e16e91f770ee Mon Sep 17 00:00:00 2001 From: Alain Plantec Date: Tue, 3 Dec 2024 13:43:17 +0100 Subject: [PATCH] fixed cursor element in not editable but selectable editor element --- src/Album/AlbCursorElement.class.st | 22 ++++++++++++------- src/Album/AlbInfiniteEditorElement.class.st | 11 ++++------ ...AlbTextEditorAbstractSegmentPiece.class.st | 1 - 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/Album/AlbCursorElement.class.st b/src/Album/AlbCursorElement.class.st index 19f7a82..4512779 100644 --- a/src/Album/AlbCursorElement.class.st +++ b/src/Album/AlbCursorElement.class.st @@ -65,18 +65,24 @@ AlbCursorElement >> newBlinkingTask [ ] { #category : #'private - focus' } -AlbCursorElement >> onGotFocus [ - - self background: self focusedBackground. - self startBlinkingTask - +AlbCursorElement >> onGotFocusIn: anEditorElement [ + + anEditorElement isEditable + ifTrue: [ + self background: self focusedBackground. + self startBlinkingTask ] + ifFalse: [ + self stopBlinkingTask. + self background: BlBackground transparent ] ] { #category : #'private - focus' } -AlbCursorElement >> onLostFocus [ +AlbCursorElement >> onLostFocusIn: anEditorElement [ - self background: self defaultBlurredBackground. - self stopBlinkingTask + anEditorElement isEditable + ifTrue: [ self background: self defaultBlurredBackground ] + ifFalse: [ self background: BlBackground transparent ]. + self stopBlinkingTask ] { #category : #initialization } diff --git a/src/Album/AlbInfiniteEditorElement.class.st b/src/Album/AlbInfiniteEditorElement.class.st index 33afdb4..acfb09b 100644 --- a/src/Album/AlbInfiniteEditorElement.class.st +++ b/src/Album/AlbInfiniteEditorElement.class.st @@ -273,7 +273,6 @@ AlbInfiniteEditorElement >> infinite [ AlbInfiniteEditorElement >> initialize [ super initialize. - self initializeCursorElement. self mode: self defaultMode. self matchParent ] @@ -284,6 +283,7 @@ AlbInfiniteEditorElement >> initializeCursorElement [ If not, dbl clicking will not work because the target of the first click may be different from the one of the second click" + cursorElement ifNotNil: [ cursorElement removeFromParent ]. cursorElement := AlbCursorElement new background: self defaultCursorBackground; yourself @@ -337,6 +337,7 @@ AlbInfiniteEditorElement >> mode: anEditabilityMode [ mode = anEditabilityMode ifTrue: [ ^ self ]. mode := anEditabilityMode. + self initializeCursorElement. self dispatchEvent: AlbInfiniteModeChangedEvent new ] @@ -383,11 +384,7 @@ AlbInfiniteEditorElement >> onExtentChanged [ AlbInfiniteEditorElement >> onGotFocus [ self editor onGotFocus. - self cursorElement onGotFocus. - self cursorElement hasParent ifFalse: [ - self selecter - from: 0 to: 0; - select ] + self cursorElement onGotFocusIn: self ] { #category : #'hooks - layout' } @@ -401,7 +398,7 @@ AlbInfiniteEditorElement >> onLayoutDone [ AlbInfiniteEditorElement >> onLostFocus [ self editor onLostFocus. - self cursorElement onLostFocus + self cursorElement onLostFocusIn: self ] { #category : #'hooks - scrolling' } diff --git a/src/Album/AlbTextEditorAbstractSegmentPiece.class.st b/src/Album/AlbTextEditorAbstractSegmentPiece.class.st index 62bd7e1..ad1ab6f 100644 --- a/src/Album/AlbTextEditorAbstractSegmentPiece.class.st +++ b/src/Album/AlbTextEditorAbstractSegmentPiece.class.st @@ -19,7 +19,6 @@ AlbTextEditorAbstractSegmentPiece >> addCursor: aPieceElement of: aLineSegment i (globalCursor insideSubText: self of: aLineSegment) ifFalse: [^self ]. currentCursor := self globalCursorToLocal: globalCursor. "tell to add the new cursor" - anEditorElement isEditable ifFalse: [ ^ self ]. self onCursorAdded: currentCursor to: aPieceElement in: anEditorElement ]