--- a/UserConfirmation.st Sat Nov 22 11:45:20 2008 +0100
+++ b/UserConfirmation.st Sat Nov 22 11:53:08 2008 +0100
@@ -12,7 +12,7 @@
"{ Package: 'stx:libbasic' }"
UserNotification subclass:#UserConfirmation
- instanceVariableNames:'canCancel defaultAnswerInDialog'
+ instanceVariableNames:'canCancel defaultAnswerInDialog defaultAnswer'
classVariableNames:''
poolDictionaries:''
category:'Kernel-Exceptions-Notifications'
@@ -88,20 +88,20 @@
canCancel := something.
!
-defaultAnswerInDialog
+defaultAnswer
"used to pass information from the raiser to the GUI dialog.
Specifies, which answer of the three (yes/no/cancel) should be the return-key-default.
If not specified, the cancel-key will be the default"
- ^ defaultAnswerInDialog
+ ^ defaultAnswer
!
-defaultAnswerInDialog:aBooleanOrNil
+defaultAnswer:aBooleanOrNil
"used to pass information from the raiser to the GUI dialog.
Specifies, which answer of the three (yes/no/cancel) should be the return-key-default.
If not specified, the cancel-key will be the default"
- defaultAnswerInDialog := aBooleanOrNil
+ defaultAnswer := aBooleanOrNil
! !
!UserConfirmation methodsFor:'default actions'!
@@ -116,33 +116,30 @@
self hasDialog ifTrue:[
self canCancel ifTrue:[
- ^ Dialog confirmWithCancel:text default:defaultAnswerInDialog
+ ^ Dialog confirmWithCancel:text default:defaultAnswer
] ifFalse:[
- ^ Dialog confirm:text default:defaultAnswerInDialog
+ ^ Dialog confirm:text default:defaultAnswer
].
].
"
on systems without GUI, simply show
- the message on the Transcript and assume, that he would have typed 'yes'.
+ the message on the Transcript and assume, that he would have typed 'yes' (or the defaultAnswer).
"
- retVal := defaultAnswerInDialog notNil
- ifTrue:[ defaultAnswerInDialog ]
+ retVal := defaultAnswer notNil
+ ifTrue:[ defaultAnswer ]
ifFalse:[
self canCancel
ifTrue:[ nil ]
- ifFalse:[ true ].
- ].
+ ifFalse:[ true ]].
- retVal isNil ifTrue:[
- retValText := 'cancel'.
- ] ifFalse:[
- retVal ifTrue:[
- retValText := 'yes'.
- ] ifFalse:[
- retValText := 'no'.
- ].
- ].
+ retValText := retVal isNil
+ ifTrue:[ 'cancel' ]
+ ifFalse:[
+ retVal
+ ifTrue:[ 'yes' ]
+ ifFalse:[ 'no' ]].
+
Transcript
show:('User confirmation requested (assuming %1): ' bindWith:retValText);
showCR:text.
@@ -156,5 +153,5 @@
!UserConfirmation class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UserConfirmation.st,v 1.4 2008-11-22 10:45:20 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UserConfirmation.st,v 1.5 2008-11-22 10:53:08 cg Exp $'
! !