Skip to content

Commit

Permalink
fixed cursor element in not editable but selectable editor element
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Dec 3, 2024
1 parent 909b75c commit bee2443
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
22 changes: 14 additions & 8 deletions src/Album/AlbCursorElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
11 changes: 4 additions & 7 deletions src/Album/AlbInfiniteEditorElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ AlbInfiniteEditorElement >> infinite [
AlbInfiniteEditorElement >> initialize [

super initialize.
self initializeCursorElement.
self mode: self defaultMode.
self matchParent
]
Expand All @@ -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
Expand Down Expand Up @@ -337,6 +337,7 @@ AlbInfiniteEditorElement >> mode: anEditabilityMode [

mode = anEditabilityMode ifTrue: [ ^ self ].
mode := anEditabilityMode.
self initializeCursorElement.
self dispatchEvent: AlbInfiniteModeChangedEvent new
]

Expand Down Expand Up @@ -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' }
Expand All @@ -401,7 +398,7 @@ AlbInfiniteEditorElement >> onLayoutDone [
AlbInfiniteEditorElement >> onLostFocus [

self editor onLostFocus.
self cursorElement onLostFocus
self cursorElement onLostFocusIn: self
]

{ #category : #'hooks - scrolling' }
Expand Down
1 change: 0 additions & 1 deletion src/Album/AlbTextEditorAbstractSegmentPiece.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
]

Expand Down

0 comments on commit bee2443

Please sign in to comment.