'From Squeak3.7alpha of 11 September 2003 [latest update: #5816] on 23 March 2004 at 8:24:47 am'! "Change Set: FocusFixes-rr Date: 23 March 2004 Author: Romain Robbes V3 : make the cursor disappear when there is no selection, and the TextMorph is not focused. V2 : provides more visual feedback by changing the selection color upon focus change, as suggested by Hern‡n Tylim. Makes the selected text in a TextMorph not disappear when the morph loses focus, by removing the call to releaseEditor in TextMorph>>keyboardFocusChange: . This makes the TextMorphs' behavior more consistent with text panes in the host platforms, and makes Squeak a more consistent with itself, as this will allow all menus to behave according to the menuKeyboardControl preference, including the ones in a paragraph. Also included are the changes in PluggableTextMorph and StrikeFont, to allow menus to be invoked modally, and thus having keyboard control if the preference is set"! Object subclass: #NewParagraph instanceVariableNames: 'text textStyle firstCharacterIndex container lines positionWhenComposed offsetToEnd maxRightX selectionStart selectionStop wantsColumnBreaks focused ' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Text Support'! !NewParagraph methodsFor: 'access' stamp: 'rr 3/22/2004 12:42'! focused focused ifNil: [focused := false]. ^ focused! ! !NewParagraph methodsFor: 'access' stamp: 'rr 3/22/2004 12:41'! focused: aBoolean focused := aBoolean! ! !NewParagraph methodsFor: 'display' stamp: 'rr 3/22/2004 19:56'! insertionPointColor self focused ifFalse: [^ Color transparent]. ^ Display depth <= 2 ifTrue: [Color black] ifFalse: [Preferences insertionPointColor]! ! !NewParagraph methodsFor: 'display' stamp: 'rr 3/23/2004 19:52'! selectionColor | color | Display depth = 1 ifTrue: [^ Color veryLightGray]. Display depth = 2 ifTrue: [^ Color gray]. color := Preferences textHighlightColor. self focused ifFalse: [color := color alphaMixed: 0.2 with: Color veryVeryLightGray]. ^ color! ! !PluggableTextMorph methodsFor: 'menu commands' stamp: 'rr 3/10/2004 09:29'! yellowButtonActivity "Called when the shifted-menu's 'more' item is chosen" | menu | (menu _ self getMenu: false) ifNotNil: ["Set up to use perform:orSendTo: for model/view dispatch" menu setInvokingView: self. menu invokeModal]! ! !PluggableTextMorph methodsFor: 'scroll bar events' stamp: 'rr 3/10/2004 09:30'! scrollBarMenuButtonPressed: event "The menu button in the scrollbar was pressed; put up the menu" | menu | (menu _ self getMenu: event shiftPressed) ifNotNil: ["Set up to use perform:orSendTo: for model/view dispatch" menu setInvokingView: self. menu invokeModal]! ! !PluggableTextMorph methodsFor: 'scroll bar events' stamp: 'rr 3/10/2004 09:29'! yellowButtonActivity: shiftKeyState "Invoke the text-editing menu" | menu | (menu _ self getMenu: shiftKeyState) ifNotNil: [menu setInvokingView: self. menu invokeModal]! ! !StrikeFont class methodsFor: 'instance creation' stamp: 'rr 3/23/2004 10:02'! fromUser: priorFont "rr 3/23/2004 10:02 : made the menu invoked modally, thus allowing keyboard control" "StrikeFont fromUser" "Present a menu of available fonts, and if one is chosen, return it. Otherwise return nil." | fontList fontMenu style active ptMenu label spec font | fontList _ StrikeFont actualFamilyNames. fontMenu _ MenuMorph new defaultTarget: self. fontList do: [:fontName | style _ TextStyle named: fontName. active _ priorFont familyName sameAs: fontName. ptMenu _ MenuMorph new defaultTarget: self. style pointSizes do: [:pt | (active and:[pt = priorFont pointSize]) ifTrue:[label _ ''] ifFalse:[label _ '']. label _ label, pt printString, ' pt'. ptMenu add: label target: fontMenu selector: #modalSelection: argument: {fontName. pt}]. style isTTCStyle ifTrue: [ ptMenu add: 'new size' target: style selector: #addNewFontSizeDialog: argument: {fontName. fontMenu}. ]. active ifTrue:[label _ ''] ifFalse:[label _ '']. label _ label, fontName. fontMenu add: label subMenu: ptMenu]. spec _ fontMenu invokeModal. spec ifNil: [^ nil]. style _ TextStyle named: spec first. style ifNil: [^ self]. font _ style fonts detect: [:any | any pointSize = spec last] ifNone: [nil]. ^ font! ! !TextMorph methodsFor: 'event handling' stamp: 'rr 3/22/2004 13:47'! keyboardFocusChange: aBoolean "rr 3/21/2004 22:55 : removed the #ifFalse: branch, which was responsible of the deselection of text when the paragraph lost focus. This way selection works in a more standard way, and this permits the menu keyboard control to be really effective" paragraph focused: aBoolean. aBoolean ifTrue: ["A hand is wanting to send us characters..." self hasFocus ifFalse: [self editor "Forces install"]]. self changed. ! ! Object subclass: #NewParagraph instanceVariableNames: 'text textStyle firstCharacterIndex container lines positionWhenComposed offsetToEnd maxRightX selectionStart selectionStop wantsColumnBreaks focused' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Text Support'!