DialogBox.st
changeset 1707 c14a2460b698
parent 1705 1a126505ac49
child 1708 dc23c5ca439e
equal deleted inserted replaced
1706:eb2f9e689f5e 1707:c14a2460b698
  1351      The strings for cancel, no and yes are to be passed in
  1351      The strings for cancel, no and yes are to be passed in
  1352      buttonLabels; 
  1352      buttonLabels; 
  1353      The default argument (if non-nil) defines the index of the 
  1353      The default argument (if non-nil) defines the index of the 
  1354      return button (1 to 3)"
  1354      return button (1 to 3)"
  1355 
  1355 
       
  1356     ^ self
       
  1357         confirmWithCancel:aString 
       
  1358         labels:buttonLabels 
       
  1359         values:#(nil false true)
       
  1360         default:default
       
  1361 
       
  1362     "
       
  1363      Transcript showCR:(
       
  1364          Dialog 
       
  1365             confirmWithCancel:'really ?'
       
  1366                        labels:#('mhmh' 'maybe' 'definitely')
       
  1367                       default:3
       
  1368      )
       
  1369     "
       
  1370 
       
  1371     "Created: / 18.10.1996 / 14:50:51 / cg"
       
  1372     "Modified: / 21.10.1998 / 15:49:16 / cg"
       
  1373 !
       
  1374 
       
  1375 confirmWithCancel:aString labels:buttonLabels values:buttonValues default:default
       
  1376     "launch a Dialog, which allows user to click on any button.
       
  1377      Return the corresponding value from the values array.
       
  1378      The labels for for the buttons are to be passed in
       
  1379      buttonLabels; 
       
  1380      The default argument (if non-nil) defines the index of the 
       
  1381      return button (1 to n)"
       
  1382 
  1356     |box answer|
  1383     |box answer|
  1357 
  1384 
  1358     box := OptionBox title:aString numberOfOptions:3. 
  1385     box := OptionBox title:aString numberOfOptions:3. 
  1359     box buttonTitles:buttonLabels
  1386     box buttonTitles:buttonLabels
  1360 	     actions:(Array with:[answer := nil]
  1387              actions:(buttonValues collect:[:v | [answer := v]]).
  1361 			    with:[answer := false] 
  1388 
  1362 			    with:[answer := true]
       
  1363 		     ).
       
  1364     default notNil ifTrue:[box defaultButtonIndex:default].
  1389     default notNil ifTrue:[box defaultButtonIndex:default].
  1365     box label:(self classResources string:'confirm').
  1390     box label:(self classResources string:'confirm').
  1366     box showAtPointer.
  1391     box showAtPointer.
  1367     box actions:nil.
  1392     box actions:nil.
  1368     box destroy.
  1393     box destroy.
  1369     ^ answer
  1394     ^ answer
  1370 
  1395 
  1371     "
  1396     "
  1372      Dialog 
  1397      Transcript showCR:(
  1373 	confirmWithCancel:'really ?'
  1398          Dialog 
  1374 		   labels:#('mhmh' 'maybe' 'definitely')
  1399             confirmWithCancel:'really ?'
  1375 		  default:3
  1400                        labels:#('mhmh' 'maybe' 'definitely')
  1376     "
  1401                        values:#(1 2 3)
  1377 
  1402                       default:3
  1378     "Created: 18.10.1996 / 14:50:51 / cg"
  1403      )
  1379     "Modified: 14.11.1996 / 16:06:23 / cg"
  1404     "
       
  1405 
       
  1406     "Created: / 18.10.1996 / 14:50:51 / cg"
       
  1407     "Modified: / 21.10.1998 / 15:48:33 / cg"
  1380 ! !
  1408 ! !
  1381 
  1409 
  1382 !DialogBox class methodsFor:'defaults'!
  1410 !DialogBox class methodsFor:'defaults'!
  1383 
  1411 
  1384 defaultLabel
  1412 defaultLabel
  5790 ! !
  5818 ! !
  5791 
  5819 
  5792 !DialogBox class methodsFor:'documentation'!
  5820 !DialogBox class methodsFor:'documentation'!
  5793 
  5821 
  5794 version
  5822 version
  5795     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.121 1998-10-09 14:14:40 cg Exp $'
  5823     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.122 1998-10-21 13:50:45 cg Exp $'
  5796 ! !
  5824 ! !
  5797 DialogBox initialize!
  5825 DialogBox initialize!