'From Squeak3.5 of ''11 April 2003'' [latest update: #5180] on 30 October 2003 at 12:14:11 pm'! ScrollPane subclass: #PluggableTextMorph instanceVariableNames: 'textMorph getTextSelector setTextSelector getSelectionSelector hasUnacceptedEdits askBeforeDiscardingEdits selectionInterval hasEditingConflicts initialText ' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Windows'! !PluggableTextMorph methodsFor: 'initialization' stamp: 'sumim 10/30/2003 11:57'! on: anObject text: getTextSel accept: setTextSel readSelection: getSelectionSel menu: getMenuSel self model: anObject. getTextSelector _ getTextSel. setTextSelector _ setTextSel. getSelectionSelector _ getSelectionSel. getMenuSelector _ getMenuSel. self borderWidth: 1. self setText: self getText. self initialText: self getText. self setSelection: self getSelection! ! !PluggableTextMorph methodsFor: 'menu commands' stamp: 'sumim 10/30/2003 12:01'! 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: []. initialText _ textMorph asText copy! ! !PluggableTextMorph methodsFor: 'menu commands' stamp: 'sumim 10/30/2003 12:06'! cancel self setText: ((self canDiscardEdits and: [(self hasProperty: #alwaysAccept) not]) ifTrue: [self getText] ifFalse: [self initialText]). self setSelection: self getSelection. getTextSelector == #annotation ifFalse: [(model dependents detect: [:dep | (dep isKindOf: PluggableTextMorph) and: [dep getTextSelector == #annotation]] ifNone: [nil]) doIfNotNil: [:aPane | model changed: #annotation]]! ! !PluggableTextMorph methodsFor: 'accessing' stamp: 'sumim 10/30/2003 12:13'! initialText ^ initialText ifNil: [initialText _ self getText]! ! !PluggableTextMorph methodsFor: 'accessing' stamp: 'sumim 10/30/2003 12:08'! initialText: aText initialText _ aText! ! PluggableTextMorph allSubInstances do: [ :each | each initialText: each getText]!