Skip to content

Commit

Permalink
Correct clicking behavior on BrEditor scroll bar
Browse files Browse the repository at this point in the history
  • Loading branch information
refactoringdr committed Aug 6, 2024
1 parent 57f70e2 commit 25400ac
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/Brick/BrEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,12 @@ BrEditor >> beReadOnlyWithoutSelection [

{ #category : #accessing }
BrEditor >> computeVerticalScrollExtent [
^ (self layout
findFirstVisibleChildClosestToEndCompletelyVisible: true
acceptPartiallyVisible: true) segment textEnd
- (self layout
findFirstVisibleChildClosestToStartCompletelyVisible: true
acceptPartiallyVisible: true) segment textStart
^ self lastVisibleSegment textEnd - self firstVisibleSegment textStart
]

{ #category : #accessing }
BrEditor >> computeVerticalScrollOffset [
^ (self layout
findFirstVisibleChildClosestToStartCompletelyVisible: true
acceptPartiallyVisible: true) segment textStart
^ self firstVisibleSegment textStart
]

{ #category : #accessing }
Expand Down Expand Up @@ -101,6 +94,13 @@ BrEditor >> editor: aBrTextEditor [
aBrTextEditor consumeClickEvent: false
]

{ #category : #accessing }
BrEditor >> firstVisibleSegment [
^ (self layout
findFirstVisibleChildClosestToStartCompletelyVisible: true
acceptPartiallyVisible: true) segment
]

{ #category : #initialization }
BrEditor >> initialize [
super initialize.
Expand All @@ -120,6 +120,7 @@ BrEditor >> initialize [

self when: BlMouseUpEvent do: [ :anEvent | anEvent consumed: true ].
self when: BlClickEvent do: [ :anEvent | anEvent consumed: true ].
self when: BrScrollByWish do: [:aWish | self onScrollBy: aWish]
]

{ #category : #'api - editor' }
Expand Down Expand Up @@ -148,13 +149,30 @@ BrEditor >> isReadOnly [
^ self viewModel mode isReadOnly
]

{ #category : #accessing }
BrEditor >> lastVisibleSegment [
^ (self layout
findFirstVisibleChildClosestToEndCompletelyVisible: true
acceptPartiallyVisible: true) segment
]

{ #category : #'editor - operations' }
BrEditor >> navigator [
<return: #BrTextEditorNavigator>

^ self editor navigator
]

{ #category : #'api - scrolling' }
BrEditor >> onScrollBy: aWish [
| position linesOnScreen |
position := aWish delta y asInteger.
linesOnScreen := self lastVisibleSegment index - self firstVisibleSegment index.
position > self computeVerticalScrollExtent
ifTrue: [ self scrollToPosition: self lastVisibleSegment index + linesOnScreen ]
ifFalse: [ self scrollToPosition: self firstVisibleSegment index - linesOnScreen ]
]

{ #category : #'editor - operations' }
BrEditor >> selecter [
<return: #BrTextEditorSelecter>
Expand Down

0 comments on commit 25400ac

Please sign in to comment.