'From etoys2.2 of 24 September 2007 [latest update: #1773] on 15 November 2007 at 10:49:05 pm'! "Change Set: fullScreenToggle-sw Date: 15 November 2007 Author: Scott Wallace Conform to latest sugar key bindings by mapping alt-enter into toggle-full-screen, where our interpreation of 'full-screen' is that the global flaps (sugar-nav, sugar-supplies, guides) are showing; when full-screen is off, those flaps are hidden. Also extends this and other global cmd keys (show-source, cycle windows) to work when the kbd focus is a SimpleHierarchicalListView."! !ParagraphEditor methodsFor: 'typing support' stamp: 'sw 11/15/2007 14:26'! dispatchOnEnterWith: typeAheadStream "Enter key hit. Treat is as an 'accept', viz a synonym for cmd-s. If cmd key is down, treat is as a synonym for print-it. " sensor keyboard. "consume enter key" (Preferences sugarNavigator and: [sensor commandKeyPressed]) ifTrue: [ActiveWorld toggleFullScreen. ^ true]. self terminateAndInitializeAround: [ sensor commandKeyPressed ifTrue: [self printIt.] ifFalse: [self closeTypeIn: typeAheadStream. self accept]. ]. ^ true ! ! !PasteUpMorph methodsFor: 'world menu' stamp: 'sw 11/15/2007 14:41'! showSourceKeyHit "The user hit the 'show source' key on the XO. Our current take on this is simply to put up the world menu..." self logEntry. ^ self putUpShowSourceMenu: ActiveEvent title: 'etoys source' translated! ! !PasteUpMorph methodsFor: '*green' stamp: 'sw 11/15/2007 14:37'! keystrokeInWorld: evt "A keystroke was hit when no keyboard focus was set, so it is sent here to the world instead." | aChar isCmd ascii | aChar _ evt keyCharacter. (ascii _ aChar asciiValue) = 27 ifTrue: "escape key -- either put up a menu, or simply quietly gobble it" [^ Preferences escapeKeyProducesMenu ifTrue: [self putUpWorldMenuFromEscapeKey]]. ((ascii = 44) and: [(evt commandKeyPressed or: [evt controlKeyPressed])]) "show-source on XO" ifTrue: [^ self showSourceKeyHit]. ((ascii = 3) and: [(evt commandKeyPressed or: [evt controlKeyPressed])]) "toggle-full-screen" ifTrue: [^ self toggleFullScreen]. (evt controlKeyPressed not and: [(#(1 4 8 28 29 30 31 32 47) includes: ascii) "home, end, backspace, arrow keys, space, slash." and: [self keyboardNavigationHandler notNil]]) ifTrue: [self keyboardNavigationHandler navigateFromKeystroke: aChar]. isCmd _ evt commandKeyPressed and: [Preferences cmdKeysInText]. (evt commandKeyPressed and: [Preferences eToyFriendly]) ifTrue: [(aChar == $W) ifTrue: [^ self putUpWorldMenu: evt]]. (isCmd and: [Preferences honorDesktopCmdKeys]) ifTrue: [^ self dispatchCommandKeyInWorld: aChar event: evt]. "It was unhandled. Remember the keystroke." self lastKeystroke: evt keyString. self triggerEvent: #keyStroke! ! !PasteUpMorph methodsFor: '*green' stamp: 'sw 11/15/2007 18:01'! quitSqueak "Obtain a confirmation from the user, and if the answer is true, quite Squeak summarily. If running under Sugar, quit wiithout the confirmation dialog. Not current in the flow-of-control, but useful to call if one were to implement a ctl-q shortcut for quitting (currently done by Sugar if running under sugar.)" SugarLauncher isRunningInSugar ifTrue: [^ SugarLauncher current quit]. (self confirm: 'Are you sure you want to Quit Squeak?' translated) ifFalse: [^ self]. SmalltalkImage current snapshot: false andQuit: true ! ! !PasteUpMorph methodsFor: '*green' stamp: 'sw 11/15/2007 14:04'! toggleFullScreen "Toggle the full-screenness; we simply flip the global flaps-suppressed setting." CurrentProjectRefactoring currentToggleFlapsSuppressed! ! !PluggableListMorph methodsFor: 'event handling' stamp: 'sw 11/15/2007 14:33'! keyStroke: event "Process keys specialKeys are things like up, down, etc. ALWAYS HANDLED modifierKeys are regular characters either 1) accompanied with ctrl, cmd or 2) any character if the list doesn't want to handle basic keys (handlesBasicKeys returns false) basicKeys are any characters" | aChar aSpecialKey | (self scrollByKeyboard: event) ifTrue: [^self]. aChar _ event keyCharacter. Preferences sugarNavigator ifTrue: [(aChar = Character enter and: [event controlKeyPressed or: [event commandKeyPressed]]) ifTrue: [^ ActiveWorld toggleFullScreen]]. aSpecialKey _ aChar asciiValue. aSpecialKey < 32 ifTrue: [^ self specialKeyPressed: aSpecialKey]. (event anyModifierKeyPressed or: [self handlesBasicKeys not]) ifTrue: [^ self modifierKeyPressed: aChar]. ^ self basicKeyPressed: aChar! ! !SimpleHierarchicalListMorph methodsFor: 'private' stamp: 'sw 11/15/2007 22:47'! keyStroke: event "Process potential command keys" | args aCharacter | aCharacter := event keyCharacter. (aCharacter = $, and: [event commandKeyPressed or: [event controlKeyPressed]]) ifTrue: [^ ActiveWorld showSourceKeyHit]. (aCharacter asciiValue = 92 and: [event commandKeyPressed]) ifTrue: ["cycle windows" ^ SystemWindow rotateWindows]. Preferences sugarNavigator ifTrue: [(aCharacter = Character enter and: [event controlKeyPressed or: [event commandKeyPressed]]) ifTrue: [ActiveWorld toggleFullScreen. ^ true]]. (self scrollByKeyboard: event) ifTrue: [^self]. (self arrowKey: aCharacter) ifTrue: [^true]. keystrokeActionSelector isNil ifTrue: [^false]. (args := keystrokeActionSelector numArgs) = 1 ifTrue: [^model perform: keystrokeActionSelector with: aCharacter]. args = 2 ifTrue: [^model perform: keystrokeActionSelector with: aCharacter with: self]. ^self error: 'The keystrokeActionSelector must be a 1- or 2-keyword symbol'! ! SimpleHierarchicalListMorph removeSelector: #modifierKeyPressed:!