DialogBox.st
changeset 4058 6c30a8f944f5
parent 3944 d5ed8d618608
child 4093 9afc4af5a88a
equal deleted inserted replaced
4057:314415319f37 4058:6c30a8f944f5
  4511     "
  4511     "
  4512 
  4512 
  4513     "Modified: / 02-03-2007 / 12:08:02 / cg"
  4513     "Modified: / 02-03-2007 / 12:08:02 / cg"
  4514 !
  4514 !
  4515 
  4515 
       
  4516 choose:aString fromList:list values:listValues buttons:buttonLabels values:buttonValues lines:maxLines cancel:cancelBlock postBuildBlock:postBuildBlock
       
  4517     "launch a Dialog showing the message and list.
       
  4518      The user can select an item and click ok; in this case, the corresponding value
       
  4519      from listValues is returned (doubleclick works as well). 
       
  4520      The list may be suppressed (if the list arg is nil).
       
  4521      Below the list, an optional row of buttons is shown, which can also be
       
  4522      clicked upon, and a corresponding value from buttonValues is returned.
       
  4523      If cancel is pressed, the value of cancelBlock is returned.
       
  4524      Pressing ok without a selection is treated like cancel."
       
  4525 
       
  4526     ^ self
       
  4527         choose:aString 
       
  4528         fromList:list values:listValues 
       
  4529         buttons:buttonLabels values:buttonValues 
       
  4530         lines:maxLines 
       
  4531         cancel:cancelBlock 
       
  4532         multiple:false
       
  4533         postBuildBlock:postBuildBlock.
       
  4534 
       
  4535 
       
  4536     "
       
  4537      full example:
       
  4538 
       
  4539          Transcript showCR:(
       
  4540              Dialog 
       
  4541                 choose:'choose any' 
       
  4542                 fromList:#('one' 'two' 'three' 'four') 
       
  4543                 values:#(1 2 3 4) 
       
  4544                 buttons:#('five' 'six' 'seven')
       
  4545                 values:#(5 6 7)
       
  4546                 lines:10 
       
  4547                 cancel:nil
       
  4548          )
       
  4549 
       
  4550 
       
  4551      no buttons:
       
  4552 
       
  4553          Transcript showCR:(
       
  4554              Dialog 
       
  4555                 choose:'choose any' 
       
  4556                 fromList:#('one' 'two' 'three' 'four') 
       
  4557                 values:#(1 2 3 4) 
       
  4558                 buttons:nil
       
  4559                 values:nil
       
  4560                 lines:4
       
  4561                 cancel:nil
       
  4562          )
       
  4563 
       
  4564 
       
  4565      no list (lines argument is ignored):
       
  4566 
       
  4567          Transcript showCR:(
       
  4568              Dialog 
       
  4569                 choose:'choose any' 
       
  4570                 fromList:nil
       
  4571                 values:nil
       
  4572                 buttons:#('one' 'two' 'three' 'four') 
       
  4573                 values:#(1 2 3 4) 
       
  4574                 lines:nil
       
  4575                 cancel:nil
       
  4576          )
       
  4577 
       
  4578 
       
  4579       full including cancel value:
       
  4580 
       
  4581          Transcript showCR:(
       
  4582              Dialog 
       
  4583                 choose:'choose example' 
       
  4584                 fromList:#('one' 'two' 'three' 'four') 
       
  4585                 values:#(1 2 3 4) 
       
  4586                 buttons:#('five' 'six' 'seven')
       
  4587                 values:#(5 6 7)
       
  4588                 lines:4
       
  4589                 cancel:[Transcript flash. #aborted]
       
  4590          )
       
  4591 
       
  4592 
       
  4593      degenerated:
       
  4594 
       
  4595          Transcript showCR:(
       
  4596              Dialog 
       
  4597                 choose:'choose any' 
       
  4598                 fromList:nil
       
  4599                 values:nil
       
  4600                 buttons:nil
       
  4601                 values:nil
       
  4602                 lines:nil 
       
  4603                 cancel:nil
       
  4604          )
       
  4605 
       
  4606 
       
  4607     "
       
  4608 
       
  4609     "Modified: / 02-03-2007 / 12:08:12 / cg"
       
  4610 !
       
  4611 
  4516 choose:aString fromList:list values:listValues initialSelection:initialListSelectionOrNil buttons:buttonLabels values:buttonValues default:defaultValue lines:maxLines cancel:cancelBlock multiple:multiple postBuildBlock:aBlockOrNil
  4612 choose:aString fromList:list values:listValues initialSelection:initialListSelectionOrNil buttons:buttonLabels values:buttonValues default:defaultValue lines:maxLines cancel:cancelBlock multiple:multiple postBuildBlock:aBlockOrNil
  4517     "launch a Dialog showing the message and list.
  4613     "launch a Dialog showing the message and list.
  4518      The user can select an item and click ok; in this case, the corresponding value
  4614      The user can select an item and click ok; in this case, the corresponding value
  4519      from listValues is returned (doubleclick works as well). 
  4615      from listValues is returned (doubleclick works as well). 
  4520      The list may be suppressed (if the list arg is nil).
  4616      The list may be suppressed (if the list arg is nil).
  4635         aBlockOrNil value:box
  4731         aBlockOrNil value:box
  4636     ].
  4732     ].
  4637     windowTitle notNil ifTrue:[
  4733     windowTitle notNil ifTrue:[
  4638         box label:windowTitle.
  4734         box label:windowTitle.
  4639     ].
  4735     ].
       
  4736 
  4640     self showBox:box.
  4737     self showBox:box.
  4641 
  4738 
  4642     box accepted ifTrue:[
  4739     box accepted ifTrue:[
  4643         (sel := listView selection) notNil ifTrue:[
  4740         (sel := listView selection) notNil ifTrue:[
  4644             box destroy. 
  4741             box destroy. 
  8898 ! !
  8995 ! !
  8899 
  8996 
  8900 !DialogBox class methodsFor:'documentation'!
  8997 !DialogBox class methodsFor:'documentation'!
  8901 
  8998 
  8902 version
  8999 version
  8903     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.290 2009-09-29 13:04:54 cg Exp $'
  9000     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.291 2009-11-02 11:25:05 cg Exp $'
       
  9001 !
       
  9002 
       
  9003 version_CVS
       
  9004     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.291 2009-11-02 11:25:05 cg Exp $'
  8904 ! !
  9005 ! !
  8905 
  9006 
  8906 DialogBox initialize!
  9007 DialogBox initialize!