'From Squeak6.0alpha of 26 April 2018 [latest update: #17922] on 27 April 2018 at 10:44:37 am'!

!ListChooser methodsFor: 'actions' stamp: 'mt 4/27/2018 10:43'!
accept
	"if the user submits with no valid entry, make them start over"
	
	| choice |
	self canAccept ifFalse: [
		self canAdd ifTrue: [^ self add].
		^ self changed: #textSelection].
	
	choice := self selectedItem.
	
	self canAdd ifTrue: [
		"Ask the user whether to add the new item or choose the list selection."
		(UserDialogBoxMorph
			confirm: 'You can either choose an existing item or add a new one.\What do you want?' translated withCRs
			title: 'Choose or Add' translated
			trueChoice: choice asString
			falseChoice: self searchText asString at: ActiveHand position)
				ifNil: ["Cancelled" self result: nil]
				ifNotNil: [:answer |
					answer ifTrue: [self result: choice] ifFalse: [self result: self searchText asString]]
		] ifFalse: [self result: choice].
		
	
	self changed: #close.! !


!UserDialogBoxMorph class methodsFor: 'utilities' stamp: 'mt 4/27/2018 10:39'!
confirm: aString title: titleString trueChoice: trueChoice falseChoice: falseChoice at: aPointOrNil
	"UserDialogBoxMorph confirm: 'Make your choice carefully' withCRs title: 'Do you like chocolate?' trueChoice: 'Oh yessir!!' falseChoice: 'Not so much...'"
	^self new
		title: titleString;
		message: aString;
		createButton: trueChoice translated value: true;
		createButton: falseChoice translated value: false;
		createCancelButton: 'Cancel' translated translated value: nil;
		selectedButtonIndex: 1;
		registerKeyboardShortcuts;
		preferredPosition: (aPointOrNil ifNil: [ActiveWorld center]);
		getUserResponse! !

!UserDialogBoxMorph class methodsFor: 'utilities' stamp: 'mt 4/27/2018 10:40'!
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@212"
	^self new
		title: titleString;
		message: aString;
		createButton: trueChoice translated value: true;
		createButton: falseChoice translated value: false;
		createCancelButton: 'Cancel' translated translated value: nil;
		selectedButtonIndex: (default ifTrue: [1] ifFalse: [2]);
		registerKeyboardShortcuts;
		preferredPosition: (aPointOrNil ifNil: [ActiveWorld center]);
		getUserResponseAfter: seconds! !

