[squeak-dev] The Inbox: Morphic-laza.573.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Sep 14 10:42:05 UTC 2011


Alexander Lazarević uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-laza.573.mcz

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

Name: Morphic-laza.573
Author: laza
Time: 14 September 2011, 12:38:56.543 pm
UUID: 49ca38c3-194b-4085-8fee-3f96c328c73f
Ancestors: Morphic-nice.572

Adds the option of a timeout to UserDialogBoxMorph. This lets you do things like:

UserDialogBoxMorph inform: 'Squeak is great' timeout: 5.

=============== Diff against Morphic-nice.572 ===============

Item was changed:
  AlignmentMorph subclass: #UserDialogBoxMorph
+ 	instanceVariableNames: 'titleMorph labelMorph buttonRow value selectedButton cancelButton timeout autoCloseProcess'
- 	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 changed:
  ----- Method: UserDialogBoxMorph class>>confirm:orCancel: (in category 'utilities') -----
  confirm: aString orCancel: cancelBlock
+ 	"UserDialogBoxMorph
+ 		confirm: 'Do you like chocolate?'
+ 		orCancel: [UserDialogBoxMorph inform: 'I''ll ask you later then']"
- 	"UserDialogBoxMorph confirm: 'Do you like chocolate?'"
  	^self confirm: aString orCancel: cancelBlock at: nil!

Item was changed:
  ----- Method: UserDialogBoxMorph class>>confirm:orCancel:at: (in category 'utilities') -----
  confirm: aString orCancel: cancelBlock at: aPointOrNil
+ 	"UserDialogBoxMorph
+ 		confirm: 'Do you like chocolate?'
+ 		orCancel: [UserDialogBoxMorph inform: 'I''ll ask you later then']
+ 		at: (Display width // 2)@(Display height * 0.38) rounded"
  	
  	^(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 ]!

Item was added:
+ ----- Method: UserDialogBoxMorph class>>confirm:timeout: (in category 'utilities') -----
+ confirm: aString timeout: seconds
+ 	"UserDialogBoxMorph confirm: 'Do you like chocolate?' timeout: 5"
+ 	^self confirm: aString title: 'Please confirm:' timeout: seconds!

Item was added:
+ ----- Method: UserDialogBoxMorph class>>confirm:title:timeout: (in category 'utilities') -----
+ confirm: aString title: titleString timeout: seconds
+ 	"UserDialogBoxMorph confirm: 'Make your choice carefully' withCRs title: 'Do you like chocolate?' timeout: 3"
+ 	^self confirm: aString title: titleString timeout: seconds at: nil!

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

Item was changed:
  ----- Method: UserDialogBoxMorph class>>inform: (in category 'utilities') -----
  inform: aString
  	"UserDialogBoxMorph inform: 'Squeak is great!!'"
+ 	^self inform: aString timeout: nil!
- 	^self inform: aString title: 'Note:'!

Item was added:
+ ----- Method: UserDialogBoxMorph class>>inform:timeout: (in category 'utilities') -----
+ inform: aString timeout: seconds
+ 	"UserDialogBoxMorph inform: 'Squeak is great!!' timeout: 5"
+ 	^self inform: aString title: 'Note:' timeout: seconds!

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 inform: aString title: titleString timeout: nil at: aPointOrNil!
- 	
- 	^self new
- 		title: titleString;
- 		label: aString;
- 		addSelectedCancelButton: '       OK       ' translated value: nil;
- 		runModalIn: ActiveWorld forHand: ActiveHand at: aPointOrNil!

Item was added:
+ ----- Method: UserDialogBoxMorph class>>inform:title:timeout: (in category 'utilities') -----
+ inform: aString title: titleString timeout: seconds
+ 	"UserDialogBoxMorph inform: 'Squeak is great!!' title: 'Will you look at this:' timeout: 5"
+ 	^self inform: aString title: titleString timeout: seconds at: nil!

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

Item was added:
+ ----- Method: UserDialogBoxMorph>>autoCloseBlock (in category 'running') -----
+ autoCloseBlock
+ 	^[
+ 		(Delay forSeconds: self timeout) wait.
+ 		selectedButton ifNotNil: [selectedButton performAction]
+ 	]!

Item was changed:
  ----- Method: UserDialogBoxMorph>>closeDialog: (in category 'running') -----
  closeDialog: returnValue
  	value := returnValue.
+ 	self delete.
+ 	"Make sure the autoCloseProcess will be terminated.
+ 	This needs to happen at the end of this method since our sender could be just inside the autoCloseProcess"
+ 	self stopAutoClose!
- 	self delete.!

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

Item was changed:
  ----- Method: UserDialogBoxMorph>>mouseDown: (in category 'events') -----
  mouseDown: event
+ 	self stopAutoClose.
  	"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!
- 	event hand grabMorph: self.!

Item was changed:
  ----- Method: UserDialogBoxMorph>>mouseUp: (in category 'events') -----
  mouseUp: event
+ 	self stopAutoClose.
  	"aggressively preserve focus"
+ 	event hand newMouseFocus: self!
- 	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.
+ 	self timeout ifNotNil: [autoCloseProcess := self autoCloseBlock fork].
  	[self isInWorld] whileTrue:[aWorld doOneSubCycle].
  	oldFocus ifNotNil:[aHand keyboardFocus: oldFocus].
  	^value!

Item was added:
+ ----- Method: UserDialogBoxMorph>>stopAutoClose (in category 'running') -----
+ stopAutoClose
+ 	autoCloseProcess ifNotNil: [autoCloseProcess terminate]!

Item was added:
+ ----- Method: UserDialogBoxMorph>>timeout (in category 'constructing') -----
+ timeout
+ 	^timeout!

Item was added:
+ ----- Method: UserDialogBoxMorph>>timeout: (in category 'constructing') -----
+ timeout: seconds
+ 	timeout := seconds!




More information about the Squeak-dev mailing list