'From Squeak3.8alpha of ''17 July 2004'' [latest update: #6326] on 14 November 2004 at 1:26:31 pm'! "Change Set: ScrollToShowFix Date: 14 November 2004 Author: Karl Ramberg Version 2: Fix for text panes also. A small fix to make sure that the selected list or text item is visible in the pane. "! !ScrollPane methodsFor: 'access' stamp: 'kfr 11/14/2004 10:29'! scrollToShow: aRectangle "scroll to include as much of aRectangle as possible, where aRectangle is in the scroller's local space" | range | ((aRectangle top - scroller offset y) >= 0 and: [ (aRectangle bottom - scroller offset y) <= (self innerBounds height) ]) ifTrue:[ "already visible"^self ]. range _ self vLeftoverScrollRange. scrollBar value: (range > 0 ifTrue: [((aRectangle top) / self vLeftoverScrollRange) truncateTo: scrollBar scrollDelta] ifFalse: [0]). scroller offset: -3 @ (range * scrollBar value).! ! !PluggableTextMorph methodsFor: 'editor access' stamp: 'kfr 11/14/2004 13:20'! scrollSelectionIntoView: event "Scroll my text into view if necessary and return true, else return false" | selRects delta selRect rectToTest transform cpHere | selectionInterval _ textMorph editor selectionInterval. selRects _ textMorph paragraph selectionRects. selRects isEmpty ifTrue: [^ false]. rectToTest _ selRects first merge: selRects last. transform _ scroller transformFrom: self. (event notNil and: [event anyButtonPressed]) ifTrue: "Check for autoscroll" [cpHere _ transform localPointToGlobal: event cursorPoint. cpHere y <= self top ifTrue: [rectToTest _ selRects first topLeft extent: 2@2] ifFalse: [cpHere y >= self bottom ifTrue: [rectToTest _ selRects last bottomRight extent: 2@2] ifFalse: [^ false]]]. selRect _ transform localBoundsToGlobal: rectToTest. selRect height > bounds height ifTrue: [^ false]. "Would not fit, even if we tried to scroll" (delta _ selRect amountToTranslateWithin: self innerBounds) y ~= 0 ifTrue: ["Scroll end of selection into view if necessary" self scrollBy: 0@delta y. ^ true]. ^ false! !