The Trunk: Morphic-kb.271.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-kb.271.mcz

commits-2
Andreas Raab uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-kb.271.mcz

==================== Summary ====================

Name: Morphic-kb.271
Author: kb
Time: 16 December 2009, 6:42:03 am
UUID: accc405e-f242-244e-8aad-5210b76629a0
Ancestors: Morphic-kb.270

 - added keyboard handling to UserDialogBoxMorph

=============== Diff against Morphic-ar.269 ===============

Item was added:
+ ----- Method: UserDialogBoxMorph>>selectPreviousButton (in category 'events') -----
+ selectPreviousButton
+
+ | buttons index |
+ buttons := self buttons.
+ index := (buttons indexOf: selectedButton) - 1.
+ index = 0 ifTrue: [ index := buttons size ].
+ self selectButton: (buttons at: index)!

Item was added:
+ ----- Method: UserDialogBoxMorph>>performActionOnEscapeOf: (in category 'constructing') -----
+ performActionOnEscapeOf: aButton
+
+ cancelButton := aButton!

Item was added:
+ ----- Method: UserDialogBoxMorph>>addCancelButton:value: (in category 'constructing') -----
+ addCancelButton: buttonLabel value: buttonValue
+
+ self
+ addButton: buttonLabel
+ value: buttonValue
+ selected: false
+ performActionOnEscape: true!

Item was added:
+ ----- Method: UserDialogBoxMorph>>selectNextButton (in category 'events') -----
+ selectNextButton
+
+ | buttons |
+ buttons := self buttons.
+ self selectButton: (buttons at: (buttons indexOf: selectedButton) \\ buttons size + 1)!

Item was added:
+ ----- Method: UserDialogBoxMorph>>selectButton: (in category 'events') -----
+ selectButton: aButton
+
+ self deselectSelectedButton.
+ aButton color: Color orange muchLighter.
+ selectedButton := aButton!

Item was changed:
  AlignmentMorph subclass: #UserDialogBoxMorph
+ instanceVariableNames: 'titleMorph labelMorph buttonRow value selectedButton cancelButton'
- instanceVariableNames: 'titleMorph labelMorph buttonRow value'
  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 class>>confirm:orCancel:at: (in category 'utilities') -----
  confirm: aString orCancel: cancelBlock at: aPointOrNil
+
+ ^(self new
+ title: 'Please confirm:';
+ label: aString;
+ addSelectedButton: '       Yes       ' translated value: true;
+ addButton: '        No        ' translated  value: false;
+ addCancelButton: '     Cancel     ' translated  value: nil;
+ runModalIn: ActiveWorld forHand: ActiveHand at: aPointOrNil)
+ ifNil: [ cancelBlock value ]!
- "UserDialogBoxMorph confirm: 'Do you like chocolate?'"
- | dialog resp |
- dialog := self new.
- dialog title: 'Please confirm:'.
- dialog label: aString.
- dialog addButton: '       Yes       ' translated value: true.
- dialog addButton: '        No        ' translated  value: false..
- dialog addButton: '     Cancel     ' translated  value: nil..
- resp := dialog runModalIn: ActiveWorld forHand: ActiveHand at: aPointOrNil.
- ^resp ifNil:[cancelBlock value]!

Item was changed:
  ----- Method: UserDialogBoxMorph>>addButton:value: (in category 'constructing') -----
  addButton: buttonLabel value: buttonValue
+
+ self
+ addButton: buttonLabel
+ value: buttonValue
+ selected: false
+ performActionOnEscape: false!
- "Adds a button with the given label and value.
- The value is returned if the user presses the button."
- | button |
- button := PluggableButtonMorphPlus new.
- button label: buttonLabel.
- button action:[self closeDialog: buttonValue].
- button color: self buttonColor twiceLighter.
- buttonRow addMorphBack: button.
- !

Item was added:
+ ----- Method: UserDialogBoxMorph>>addSelectedButton:value: (in category 'constructing') -----
+ addSelectedButton: buttonLabel value: buttonValue
+
+ self
+ addButton: buttonLabel
+ value: buttonValue
+ selected: true
+ performActionOnEscape: false!

Item was added:
+ ----- Method: UserDialogBoxMorph>>deselectSelectedButton (in category 'events') -----
+ deselectSelectedButton
+
+ selectedButton ifNil: [ ^self ].
+ selectedButton color: self buttonColor twiceLighter.
+ selectedButton := nil!

Item was added:
+ ----- Method: UserDialogBoxMorph>>buttons (in category 'events') -----
+ buttons
+
+ ^buttonRow submorphs select: [ :each |
+ each isKindOf: PluggableButtonMorphPlus ].!

Item was changed:
  ----- Method: UserDialogBoxMorph class>>inform:title:at: (in category 'utilities') -----
  inform: aString title: titleString at: aPointOrNil
  "UserDialogBoxMorph inform: 'Squeak is great!!' title: 'Will you look at this:'"
+
+ ^self new
+ title: titleString;
+ label: aString;
+ addSelectedCancelButton: '       OK       ' translated value: nil;
+ runModalIn: ActiveWorld forHand: ActiveHand at: aPointOrNil!
- | dialog |
- dialog := self new.
- dialog title: titleString.
- dialog label: aString.
- dialog addButton: '       OK       ' translated value: nil.
- ^dialog runModalIn: ActiveWorld forHand: ActiveHand at: aPointOrNil!

Item was added:
+ ----- Method: UserDialogBoxMorph>>addSelectedCancelButton:value: (in category 'constructing') -----
+ addSelectedCancelButton: buttonLabel value: buttonValue
+
+ self
+ addButton: buttonLabel
+ value: buttonValue
+ selected: true
+ performActionOnEscape: true!

Item was added:
+ ----- Method: UserDialogBoxMorph>>keyStroke: (in category 'events') -----
+ keyStroke: evt
+
+ | evtCharacter |
+ 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 ].!

Item was added:
+ ----- Method: UserDialogBoxMorph>>handlesKeyboard: (in category 'events') -----
+ handlesKeyboard: evt
+
+ ^true!

Item was added:
+ ----- Method: UserDialogBoxMorph>>addButton:value:selected:performActionOnEscape: (in category 'constructing') -----
+ 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.
+ button label: buttonLabel.
+ button action:[self closeDialog: buttonValue].
+ button color: self buttonColor twiceLighter.
+ isSelected ifTrue: [ self selectButton: button ].
+ performActionOnEscape ifTrue: [ self performActionOnEscapeOf: button ].
+ buttonRow addMorphBack: button.
+ !

Item was changed:
  ----- Method: UserDialogBoxMorph class>>confirm:title:at: (in category 'utilities') -----
  confirm: aString title: titleString at: aPointOrNil
  "UserDialogBoxMorph confirm: 'Make your choice carefully' withCRs title: 'Do you like chocolate?'"
+ ^self new
+ title: titleString;
+ label: aString;
+ addSelectedButton: '       Yes       ' translated value: true;
+ addCancelButton: '        No        ' translated  value: false;
+ runModalIn: ActiveWorld forHand: ActiveHand at: aPointOrNil!
- | dialog |
- dialog := self new.
- dialog title: titleString.
- dialog label: aString.
- dialog addButton: '       Yes       ' translated value: true.
- dialog addButton: '        No        ' translated  value: false..
- ^dialog runModalIn: ActiveWorld forHand: ActiveHand at: aPointOrNil!