'From Squeak3.3alpha of 12 January 2002 [latest update: #4809] on 24 March 2002 at 11:56:08 pm'! "Change Set: classListScroll-sw Date: 25 March 2002 Author: Scott Wallace Addresses two long-standing bugs, both relating to whether the selected class is properly scrolled into view in a browser or Hierarchy Browser freshly launched by some browser-requesting or hierarchy-requesting command. ¥ One was an off-by-one bug affecting the browse-it and browse-full commands, when the first class just *below* the last one visible in the unscrolled class-list-pane would not properly get scrolled into view. ¥ The other is worked around rather than fixed; it relates to hierarchy-browsers launched by browse-hierarchy or by browse-it when #alternativeBrowseIt preference is true. The workaround is to force the list selections to be made a second time, after launch; this takes extra time but results in selections being visible. ¥ Also (unrelated) fixed here is a bug wherein the hitting of the Enter key into a morphic PluggableTextMorph that was visible in an mvc project could generate an error."! !CodeHolder methodsFor: 'commands' stamp: 'sw 3/24/2002 23:52'! spawnHierarchy "Create and schedule a new class hierarchy browser on the currently selected class or meta." | newBrowser aSymbol aBehavior messageCatIndex selectedClassOrMetaClass | (selectedClassOrMetaClass _ self selectedClassOrMetaClass) ifNil: [^ self]. newBrowser _ HierarchyBrowser new initHierarchyForClass: selectedClassOrMetaClass. (aSymbol _ self selectedMessageName) ifNotNil: [aBehavior _ selectedClassOrMetaClass. messageCatIndex _ aBehavior organization numberOfCategoryOfElement: aSymbol. newBrowser messageCategoryListIndex: messageCatIndex + 1. newBrowser messageListIndex: ((aBehavior organization listAtCategoryNumber: messageCatIndex) indexOf: aSymbol)]. Browser openBrowserView: (newBrowser openSystemCatEditString: nil) label: newBrowser labelString. Smalltalk isMorphic ifTrue: "this workaround only needed in morphic" [newBrowser assureSelectionsShow]! ! !HierarchyBrowser methodsFor: 'class list' stamp: 'sw 3/24/2002 01:55'! assureSelectionsShow "This is a workaround for the fact that a hierarchy browser, when launched, often does not show the selected class" | saveCatIndex saveMsgIndex | saveCatIndex _ messageCategoryListIndex. saveMsgIndex _ messageListIndex. self classListIndex: classListIndex. self messageCategoryListIndex: saveCatIndex. self messageListIndex: saveMsgIndex! ! !PluggableListMorph methodsFor: 'selection' stamp: 'sw 3/24/2002 23:52'! selectionIndex: index "Called internally to select the index-th item." | theMorph range | (index isNil or: [index > scroller submorphs size]) ifTrue: [^ self]. (theMorph _ index = 0 ifTrue: [nil] ifFalse: [scroller submorphs at: index]) ifNotNil: [((theMorph bounds top - scroller offset y) >= 0 and: [(theMorph bounds bottom - scroller offset y) < bounds height]) ifFalse: ["Scroll into view -- should be elsewhere" range _ self leftoverScrollRange. scrollBar value: (range > 0 ifTrue: [((index-1 * theMorph height) / self leftoverScrollRange) truncateTo: scrollBar scrollDelta] ifFalse: [0]). scroller offset: -3 @ (range * scrollBar value)]]. self selectedMorph: theMorph! ! !PluggableTextMorph methodsFor: 'menu commands' stamp: 'sw 3/24/2002 23:55'! accept "Inform the model of text to be accepted, and return true if OK." | textToAccept ok saveSelection saveScrollerOffset | "sps 8/13/2001 22:41: save selection and scroll info" saveSelection _ self selectionInterval copy. saveScrollerOffset _ scroller offset copy. (self canDiscardEdits and: [(self hasProperty: #alwaysAccept) not]) ifTrue: [^ self flash]. self hasEditingConflicts ifTrue: [(self confirm: 'Caution!! This method may have been changed elsewhere since you started editing it here. Accept anyway?') ifFalse: [^ self flash]]. textToAccept _ textMorph asText. ok _ (setTextSelector == nil) or: [setTextSelector numArgs = 2 ifTrue: [model perform: setTextSelector with: textToAccept with: self] ifFalse: [model perform: setTextSelector with: textToAccept]]. ok==true ifTrue: [self setText: self getText. self hasUnacceptedEdits: false. (model dependents detect: [:dep | (dep isKindOf: PluggableTextMorph) and: [dep getTextSelector == #annotation]] ifNone: [nil]) doIfNotNil: [:aPane | model changed: #annotation]]. "sps 8/13/2001 22:41: restore selection and scroll info" ["During the step for the browser, updateCodePaneIfNeeded is called, and invariably resets the contents of the codeholding PluggableTextMorph at that time, resetting the cursor position and scroller in the process. The following line forces that update without waiting for the step, then restores the cursor and scrollbar" ok ifTrue: "(don't bother if there was an error during compile)" [(model isKindOf: CodeHolder) ifTrue: [model updateCodePaneIfNeeded]. WorldState addDeferredUIMessage: [self currentHand newKeyboardFocus: textMorph. scroller offset: saveScrollerOffset. self setScrollDeltas. self selectFrom: saveSelection first to: saveSelection last]]] on: Error do: [] ! !