[squeak-dev] The Trunk: Morphic-laza.575.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Sep 20 06:27:27 UTC 2011
Alexander Lazarević uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-laza.575.mcz
==================== Summary ====================
Name: Morphic-laza.575
Author: laza
Time: 19 September 2011, 8:51:54.838 am
UUID: 287d060c-cc1b-42a0-877c-8d04e245ecda
Ancestors: Morphic-nice.572
You can now tell a UserDialogBoxMorph to automatically trigger the preselected button after a timeout of some seconds. There is also now a method that let's you set either true or false as the default choice as in
UserDialogBoxMorph confirm: 'I like hot java' title: 'What do you say?' trueChoice: 'You bet!' falseChoice: 'Nope' default: false triggerAfter: 12 at: 121 at 212
As suggested (thanks Bert) this uses an easier implementation using morphic stepping instead of processes
=============== Diff against Morphic-nice.572 ===============
Item was changed:
AlignmentMorph subclass: #UserDialogBoxMorph
+ instanceVariableNames: 'titleMorph labelMorph buttonRow value selectedButton cancelButton timeout savedLabel'
- instanceVariableNames: 'titleMorph labelMorph buttonRow value selectedButton cancelButton'
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 added:
+ ----- Method: UserDialogBoxMorph class>>confirm:title:trueChoice:falseChoice:default:triggerAfter:at: (in category 'utilities') -----
+ confirm: aString title: titleString trueChoice: trueChoice falseChoice: falseChoice default: default triggerAfter: seconds at: aPointOrNil
+ "UserDialogBoxMorph confirm: 'I like hot java' title: 'What do you say?' trueChoice: 'You bet!!' falseChoice: 'Nope' default: false triggerAfter: 12 at: 121 at 212"
+ ^self new
+ title: titleString;
+ label: aString;
+ addButton: ' ', trueChoice translated, ' ' value: true selected: default performActionOnEscape: false;
+ addButton: ' ', falseChoice translated, ' ' value: false selected: default not performActionOnEscape: true;
+ triggerAfter: seconds;
+ runModalIn: ActiveWorld forHand: ActiveHand at: aPointOrNil!
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 ].!
Item was changed:
----- Method: UserDialogBoxMorph>>mouseDown: (in category 'events') -----
mouseDown: event
+ self stopAutoTrigger.
"Always bring me to the front since I am modal"
self comeToFront.
(self containsPoint: event position) ifFalse:[
Beeper beepPrimitive.
^self flash].
event hand grabMorph: self.!
Item was changed:
----- Method: UserDialogBoxMorph>>mouseUp: (in category 'events') -----
mouseUp: event
+ self stopAutoTrigger.
"aggressively preserve focus"
event hand newMouseFocus: self.!
Item was changed:
----- Method: UserDialogBoxMorph>>runModalIn:forHand:at: (in category 'running') -----
runModalIn: aWorld forHand: aHand at: aPointOrNil
"Ensure that we have a reasonable minimum size"
| oldFocus pos |
(ProvideAnswerNotification signal: self label asString) ifNotNil:[:answer| ^answer].
self openInWorld: aWorld.
pos := (aPointOrNil ifNil:[aHand position]) - (self fullBounds extent // 2).
self setConstrainedPosition: pos hangOut: false.
oldFocus := aHand keyboardFocus.
aHand newMouseFocus: self.
aHand newKeyboardFocus: self.
+ savedLabel := selectedButton label.
[self isInWorld] whileTrue:[aWorld doOneSubCycle].
oldFocus ifNotNil:[aHand keyboardFocus: oldFocus].
^value!
Item was added:
+ ----- Method: UserDialogBoxMorph>>step (in category 'stepping and presenter') -----
+ step
+ timeout ifNil: [^self].
+ timeout = 0
+ ifTrue: [
+ self stopStepping.
+ selectedButton performAction]
+ ifFalse: [
+ selectedButton label: savedLabel, '(', timeout printString, ')'.
+ timeout := timeout - 1]!
Item was added:
+ ----- Method: UserDialogBoxMorph>>stepTime (in category 'stepping and presenter') -----
+ stepTime
+ ^1000!
Item was added:
+ ----- Method: UserDialogBoxMorph>>stopAutoTrigger (in category 'stepping and presenter') -----
+ stopAutoTrigger
+ timeout ifNil: [^self].
+ timeout := nil.
+ self stopStepping.
+ selectedButton label: savedLabel !
Item was added:
+ ----- Method: UserDialogBoxMorph>>triggerAfter: (in category 'constructing') -----
+ triggerAfter: seconds
+ timeout := seconds!
More information about the Squeak-dev
mailing list
|