Skip to content

Commit

Permalink
Merge pull request #11583 from fmqa/Pharo11-fix-RubAbstractTextArea-S…
Browse files Browse the repository at this point in the history
…crollSize

Attempt to fix scrolling behavior in RubAbstractTextArea & friends
  • Loading branch information
Ducasse committed Sep 4, 2022
2 parents 88a8574 + 9f15fe2 commit 2a853fa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Rubric/RubAbstractTextArea.class.st
Expand Up @@ -96,6 +96,7 @@ Class {
'mouseDownPoint',
'completionEngine',
'maxLength',
'grow',
'findReplaceService',
'editing'
],
Expand Down Expand Up @@ -991,6 +992,10 @@ RubAbstractTextArea >> handleEdit: editBlock [
"Ensure that changed areas get suitably redrawn"

editBlock value.
"Fit to width on edit"
(self grow isNotNil & self grow) ifTrue: [
self width: (1 max: self maxLineWidth + self margins left + self margins right)
].
self selectionChanged "Note new selection"
]

Expand Down Expand Up @@ -1302,6 +1307,30 @@ RubAbstractTextArea >> maxLength: anInteger [
maxLength := anInteger max: 0
]

{ #category : #accessing }
RubAbstractTextArea >> grow [
"Answer whether the area should grow horizontally."

^ grow
]

{ #category : #accessing }
RubAbstractTextArea >> grow: aBool [
"Set whether the area should grow horizontally."

grow := aBool
]

{ #category : #measuring }
RubAbstractTextArea >> maxLineWidth [
"Answers with the maximum approximate pixel width across all lines"
| w |
w := 0.
self string linesDo: [ :line | w := w max: (self font widthOfString: line) ].
"check this later, not really sure about this calculation"
^ w * 6 // 5
]

{ #category : #accessing }
RubAbstractTextArea >> menuAllowed [
^ menuAllowed ifNil: [ menuAllowed := self defaultMenuAllowed ]
Expand Down
1 change: 1 addition & 0 deletions src/Rubric/RubScrolledTextMorph.class.st
Expand Up @@ -330,6 +330,7 @@ RubScrolledTextMorph >> defaultGhostTextMorph [
RubScrolledTextMorph >> defaultScrollTarget [
| textArea |
textArea := self textAreaClass new.
textArea grow: true. "Ensure morph width tracks line width"
textArea backgroundColor: Color lightGray veryMuchLighter.
^ textArea
]
Expand Down

0 comments on commit 2a853fa

Please sign in to comment.