Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.622.mcz ==================== Summary ==================== Name: Morphic-cmm.622 Author: cmm Time: 9 August 2012, 8:14:27.696 pm UUID: 2c07775c-face-4d3f-bcb0-2c230163bb41 Ancestors: Morphic-bf.621 Reduce, by one, the number of keystrokes required to exit Squeak without saving the image. The N key will now work. =============== Diff against Morphic-bf.621 =============== Item was changed: AlignmentMorph subclass: #UserDialogBoxMorph + instanceVariableNames: 'titleMorph labelMorph buttonRow value selectedButton cancelButton timeout savedLabel keyMap' - instanceVariableNames: 'titleMorph labelMorph buttonRow value selectedButton cancelButton timeout savedLabel' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Windows'! !UserDialogBoxMorph commentStamp: 'ar 12/11/2009 22:33' prior: 0! A DialogBoxMorph is Morph used in simple yes/no/confirm dialogs. Strongly modal.! Item was changed: ----- Method: UserDialogBoxMorph>>addButton:value:selected:performActionOnEscape: (in category 'constructing') ----- + addButton: buttonLabel value: buttonValue selected: isSelected performActionOnEscape: performActionOnEscape - addButton: buttonLabel value: buttonValue selected: isSelected performActionOnEscape: performActionOnEscape "Adds a button with the given label and value. The value is returned if the user presses the button." | button | + button := PluggableButtonMorphPlus new + label: buttonLabel ; + action: [ self closeDialog: buttonValue ] ; + color: self buttonColor twiceLighter. - button := PluggableButtonMorphPlus new. - button label: buttonLabel. - button action:[self closeDialog: buttonValue]. - button color: self buttonColor twiceLighter. isSelected ifTrue: [ self selectButton: button ]. + performActionOnEscape ifTrue: [ self performActionOnEscapeOf: button ]. + self registerKeyFor: button. + buttonRow addMorphBack: button! - performActionOnEscape ifTrue: [ self performActionOnEscapeOf: button ]. - buttonRow addMorphBack: button. - ! Item was added: + ----- Method: UserDialogBoxMorph>>checkAgainstKeymap: (in category 'events') ----- + checkAgainstKeymap: aCharacter + keyMap + at: aCharacter asLowercase + ifPresent: [ : foundButton | foundButton performAction ] + ifAbsent: [ "do nothing" ]! Item was changed: ----- Method: UserDialogBoxMorph>>initialize (in category 'initialization') ----- initialize | titleRow titleFill cc | super initialize. self color: Color white. self listDirection: #topToBottom; wrapCentering: #center; hResizing: #shrinkWrap; vResizing: #shrinkWrap. self layoutInset: 0@0; cellInset: 5@5. self borderStyle: BorderStyle thinGray. self useRoundedCorners; addDropShadow; shadowColor: (TranslucentColor r: 0.0 g: 0.0 b: 0.0 alpha: 0.666); shadowOffset: 1 @ 1. cc := Color gray: 0.8. titleRow := AlignmentMorph newRow. titleRow hResizing: #spaceFill; vResizing: #shrinkWrap. titleRow layoutInset: 2@5. titleRow color: cc. titleFill := GradientFillStyle ramp: {0.0 -> Color white. 1 ->cc}. titleFill radial: false; origin: titleRow topLeft; direction: 0 @ TextStyle defaultFont height. titleRow fillStyle: titleFill. titleRow fillStyle: self titleGradient. titleMorph := StringMorph new. titleMorph emphasis: 1. titleRow addMorph: titleMorph. labelMorph := TextMorph new. labelMorph margins: 5@5. labelMorph lock. buttonRow := AlignmentMorph newRow vResizing: #shrinkWrap. buttonRow hResizing: #shrinkWrap; layoutInset: 5@5; cellInset: 5@5. buttonRow color: Color transparent. + self + addMorphBack: titleRow ; + addMorphBack: labelMorph ; + addMorphBack: buttonRow ; + addDropShadow. + keyMap := Dictionary new! - self addMorphBack: titleRow. - self addMorphBack: labelMorph. - self addMorphBack: buttonRow. - self addDropShadow.! Item was changed: ----- Method: UserDialogBoxMorph>>keyStroke: (in category 'events') ----- keyStroke: evt | evtCharacter | self stopAutoTrigger. evtCharacter := evt keyCharacter. evtCharacter = Character escape ifTrue: [ ^cancelButton ifNotNil: [ cancelButton performAction ] ]. evtCharacter = Character cr ifTrue: [ ^selectedButton ifNotNil: [ selectedButton performAction ] ]. (evtCharacter = Character arrowLeft or: [ evt shiftPressed and: [ evtCharacter = Character tab ] ]) ifTrue: [ ^self selectPreviousButton ]. (evtCharacter = Character arrowRight or: [ evtCharacter = Character tab ]) ifTrue: [ + ^self selectNextButton ]. + self checkAgainstKeymap: evtCharacter! - ^self selectNextButton ].! Item was added: + ----- Method: UserDialogBoxMorph>>registerKeyFor: (in category 'constructing') ----- + registerKeyFor: button + button label do: + [ : eachChar | eachChar isAlphaNumeric ifTrue: + [ keyMap + at: eachChar asLowercase + ifPresent: [ : found | "It's already taken, don't use it." ] + ifAbsent: + [ ^ keyMap + at: eachChar asLowercase + put: button ] ] ]! |
Free forum by Nabble | Edit this page |