Skip to content

Commit

Permalink
fixing readOnlyWithSelection/editable with focus/unfocused
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Dec 18, 2024
1 parent 3ca2953 commit 26257a7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
24 changes: 14 additions & 10 deletions src/Album/AlbTextEditorMouseHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,33 @@ AlbTextEditorMouseHandler >> mouseDownEvent: anEvent [

anEvent consume.
aScreenPosition := (element
localBoundsToMine: (BlBounds origin: anEvent localPosition extent: 0.0 @ 0.0)
localBoundsToMine:
(BlBounds
origin: anEvent localPosition
extent: 0.0 @ 0.0)
fromChild: anEvent currentTarget) center.
editor := element editor.
aNavigator := editor navigator.
aTextIndex := aNavigator findTextIndexAtScreenPosition: aScreenPosition ifAbsent: [ nil ].
aTextIndex := aNavigator
findTextIndexAtScreenPosition: aScreenPosition
ifAbsent: [ nil ].

anEvent modifiers isShift
ifTrue: [
aTextIndex ifNotNil: [
ifTrue: [
aTextIndex ifNotNil: [
(editor selection contains: aTextIndex)
ifTrue: [
ifTrue: [
editor deselecter
from: aTextIndex to: editor selection indices last;
deselect ]
ifFalse: [
ifFalse: [
editor selecter
extendToIndex: aTextIndex;
select ] ] ]
ifFalse: [
(element hasFocus ) ifTrue: [
editor deselecter all deselect ] ].
ifFalse: [
element hasFocus ifTrue: [ editor deselecter all deselect ] ].
aNavigator moveToScreenPosition: aScreenPosition.
element requestFocus.
element isEnabled ifTrue: [ element requestFocus ].
aNavigator apply.

anEvent sendTo: element
Expand Down
9 changes: 5 additions & 4 deletions src/Album/AlbTextWordPieceStencil.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ AlbTextWordPieceStencil class >> readOnly [
{ #category : #'api - instantiation' }
AlbTextWordPieceStencil >> allEventHandlers [

"^ readOnly

self flag: 'To Check if it works when a #beReadonlyWithSelection is followed by a #beEditable sent'.
^ readOnly
ifTrue: [ self readOnlyWordPieceEventHandlers ]
ifFalse: [ self editableWordPieceEventHandlers ]"
self flag: 'previous version does not work when a #beReadonlyWithSelection is followed by a #beEditable sent. This is the case in ToAlbumSkin>>enabledSkinEvent: and #disabledSkinEvent:'.
^ self editableWordPieceEventHandlers
ifFalse: [ self editableWordPieceEventHandlers ]
"^ self editableWordPieceEventHandlers"
]

{ #category : #'api - instantiation' }
Expand Down

0 comments on commit 26257a7

Please sign in to comment.