DialogBox.st
changeset 4642 e2b1cd9dd459
parent 4640 6069399797c0
child 4653 81ab264cb68f
equal deleted inserted replaced
4641:febbcec12413 4642:e2b1cd9dd459
  5030      The list may be suppressed (if the list arg is nil).
  5030      The list may be suppressed (if the list arg is nil).
  5031      If a list is present, multiple controls if multiple selections are allowed.
  5031      If a list is present, multiple controls if multiple selections are allowed.
  5032      Below the list, an optional row of buttons is shown, which can also be
  5032      Below the list, an optional row of buttons is shown, which can also be
  5033      clicked upon, and a corresponding value from buttonValues is returned.
  5033      clicked upon, and a corresponding value from buttonValues is returned.
  5034      If cancel is pressed, the value of cancelBlock is returned.
  5034      If cancel is pressed, the value of cancelBlock is returned.
  5035      Pressing ok without a selection is treated like cancel."
  5035      Pressing ok without a selection returns nil or an empty collection (if multiple is true)."
  5036 
  5036 
  5037     ^ self
  5037     ^ self
  5038         choose:aString 
  5038         choose:aString 
  5039         fromList:list values:listValues 
  5039         fromList:list values:listValues 
  5040         buttons:buttonLabels values:buttonValues 
  5040         buttons:buttonLabels values:buttonValues 
  5053      The list may be suppressed (if the list arg is nil).
  5053      The list may be suppressed (if the list arg is nil).
  5054      If a list is present, multiple controls if multiple selections are allowed.
  5054      If a list is present, multiple controls if multiple selections are allowed.
  5055      Below the list, an optional row of buttons is shown, which can also be
  5055      Below the list, an optional row of buttons is shown, which can also be
  5056      clicked upon, and a corresponding value from buttonValues is returned.
  5056      clicked upon, and a corresponding value from buttonValues is returned.
  5057      If cancel is pressed, the value of cancelBlock is returned.
  5057      If cancel is pressed, the value of cancelBlock is returned.
  5058      Pressing ok without a selection is treated like cancel."
  5058      Pressing ok without a selection returns nil or an empty collection (if multiple is true)."
  5059 
  5059 
  5060     ^ self
  5060     ^ self
  5061         choose:aString 
  5061         choose:aString 
  5062         fromList:list values:listValues 
  5062         fromList:list values:listValues 
  5063         initialSelection:nil
  5063         initialSelection:nil
  5206      The list may be suppressed (if the list arg is nil).
  5206      The list may be suppressed (if the list arg is nil).
  5207      If a list is present, multiple controls if multiple selections are allowed.
  5207      If a list is present, multiple controls if multiple selections are allowed.
  5208      Below the list, an optional row of buttons is shown, which can also be
  5208      Below the list, an optional row of buttons is shown, which can also be
  5209      clicked upon, and a corresponding value from buttonValues is returned.
  5209      clicked upon, and a corresponding value from buttonValues is returned.
  5210      If cancel is pressed, the value of cancelBlock is returned.
  5210      If cancel is pressed, the value of cancelBlock is returned.
  5211      Pressing ok without a selection is treated like cancel."
  5211      Pressing ok without a selection returns nil or an empty collection (if multiple is true)."
  5212 
  5212 
  5213     ^ self
  5213     ^ self
  5214         choose:aString 
  5214         choose:aString 
  5215         fromList:list values:listValues 
  5215         fromList:list values:listValues 
  5216         initialSelection:initialListSelectionOrNil 
  5216         initialSelection:initialListSelectionOrNil 
  5232      The list may be suppressed (if the list arg is nil).
  5232      The list may be suppressed (if the list arg is nil).
  5233      If a list is present, multiple controls if multiple selections are allowed.
  5233      If a list is present, multiple controls if multiple selections are allowed.
  5234      Below the list, an optional row of buttons is shown, which can also be
  5234      Below the list, an optional row of buttons is shown, which can also be
  5235      clicked upon, and a corresponding value from buttonValues is returned.
  5235      clicked upon, and a corresponding value from buttonValues is returned.
  5236      If cancel is pressed, the value of cancelBlock is returned.
  5236      If cancel is pressed, the value of cancelBlock is returned.
  5237      Pressing ok without a selection is treated like cancel."
  5237      Pressing ok without a selection returns nil or an empty collection (if multiple is true)."
  5238 
  5238 
  5239     ^ self
  5239     ^ self
  5240         choose:aString 
  5240         choose:aString 
  5241         fromList:list values:listValues 
  5241         fromList:list values:listValues 
  5242         initialSelection:initialListSelectionOrNil 
  5242         initialSelection:initialListSelectionOrNil 
  5291      If a list is present, multiple controls if multiple selections are allowed.
  5291      If a list is present, multiple controls if multiple selections are allowed.
  5292      Below the list, an optional row of buttons is shown, which can also be
  5292      Below the list, an optional row of buttons is shown, which can also be
  5293      clicked upon, and a corresponding value from buttonValues is returned.
  5293      clicked upon, and a corresponding value from buttonValues is returned.
  5294      The buttonValue may be a block of up to 3 arguments; it gets the selection, the box and selIndices as args.
  5294      The buttonValue may be a block of up to 3 arguments; it gets the selection, the box and selIndices as args.
  5295      If cancel is pressed, the value of cancelBlock is returned.
  5295      If cancel is pressed, the value of cancelBlock is returned.
  5296      Pressing ok without a selection is treated like cancel."
  5296      Pressing ok without a selection returns nil or an empty collection (if multiple is true)."
  5297 
  5297 
  5298     |box listView panel sel haveDefault|
  5298     |box listView panel sel haveDefault|
  5299 
  5299 
  5300     box := Dialog new.
  5300     box := Dialog new.
  5301     (box addTextLabel:aString) adjust:#left.
  5301     (box addTextLabel:aString) adjust:#left.
  5422                 ^ listValues at:sel
  5422                 ^ listValues at:sel
  5423             ].
  5423             ].
  5424             ^ sel collect:[:idx | listValues at:idx]
  5424             ^ sel collect:[:idx | listValues at:idx]
  5425         ].
  5425         ].
  5426         box destroy. 
  5426         box destroy. 
  5427         ^ nil "/ ^ true.
  5427         ^ multiple ifTrue:[ #() ] ifFalse:[ nil ]
  5428     ].
  5428     ].
  5429     box destroy. 
  5429     box destroy. 
  5430     ^ cancelBlock value
  5430     ^ cancelBlock value
  5431 
  5431 
  5432     "
  5432     "
  5471      The list may be suppressed (if the list arg is nil).
  5471      The list may be suppressed (if the list arg is nil).
  5472      If a list is present, multiple controls if multiple selections are allowed.
  5472      If a list is present, multiple controls if multiple selections are allowed.
  5473      Below the list, an optional row of buttons is shown, which can also be
  5473      Below the list, an optional row of buttons is shown, which can also be
  5474      clicked upon, and a corresponding value from buttonValues is returned.
  5474      clicked upon, and a corresponding value from buttonValues is returned.
  5475      If cancel is pressed, the value of cancelBlock is returned.
  5475      If cancel is pressed, the value of cancelBlock is returned.
  5476      Pressing ok without a selection is treated like cancel."
  5476      Pressing ok without a selection returns nil or an empty collection (if multiple is true)."
  5477 
  5477 
  5478     ^ self
  5478     ^ self
  5479         choose:aString 
  5479         choose:aString 
  5480         fromList:list values:listValues 
  5480         fromList:list values:listValues 
  5481         initialSelection:initialListSelectionOrNil 
  5481         initialSelection:initialListSelectionOrNil 
  5832     "
  5832     "
  5833 
  5833 
  5834     "Modified: / 02-03-2007 / 12:08:55 / cg"
  5834     "Modified: / 02-03-2007 / 12:08:55 / cg"
  5835 !
  5835 !
  5836 
  5836 
       
  5837 chooseMultiple:aString fromList:list lines:maxLines 
       
  5838     "launch a Dialog showing the message and list.
       
  5839      The user can select any combination of items and click ok; 
       
  5840      in this case, the values from list is returned (doubleclick works as well).
       
  5841      If cancel is pressed, the value of cancelBlock is returned.
       
  5842      Pressing ok without a selection returns an empty collection."
       
  5843 
       
  5844     ^ self
       
  5845         choose:aString 
       
  5846         fromList:(list collect:[:each| each printString]) values:list
       
  5847         initialSelection:nil
       
  5848         buttons:nil values:nil
       
  5849         default:#()
       
  5850         lines:maxLines
       
  5851         cancel:nil
       
  5852         multiple:true
       
  5853         title:nil
       
  5854         postBuildBlock:nil
       
  5855 
       
  5856     "
       
  5857      Transcript showCR:(
       
  5858          Dialog 
       
  5859             chooseMultiple:'choose any combination' 
       
  5860             fromList:#(1 2 3 4 5 6 7) 
       
  5861             lines:4
       
  5862      )
       
  5863     "
       
  5864 
       
  5865     "Modified: / 02-03-2007 / 12:08:31 / cg"
       
  5866 !
       
  5867 
  5837 chooseMultiple:aString fromList:list values:listValues buttons:buttonLabels values:buttonValues lines:maxLines cancel:cancelBlock
  5868 chooseMultiple:aString fromList:list values:listValues buttons:buttonLabels values:buttonValues lines:maxLines cancel:cancelBlock
  5838     "launch a Dialog showing the message and list.
  5869     "launch a Dialog showing the message and list.
  5839      The user can select an item and click ok; in this case, the corresponding value
  5870      The user can select an item and click ok; in this case, the corresponding value
  5840      from listValues is returned (doubleclick works as well). 
  5871      from listValues is returned (doubleclick works as well). 
  5841      The list may be suppressed (if the list arg is nil).
  5872      The list may be suppressed (if the list arg is nil).
  5842      Below the list, an optional row of buttons is shown, which can also be
  5873      Below the list, an optional row of buttons is shown, which can also be
  5843      clicked upon, and a corresponding value from buttonValues is returned.
  5874      clicked upon, and a corresponding value from buttonValues is returned.
  5844      If cancel is pressed, the value of cancelBlock is returned.
  5875      If cancel is pressed, the value of cancelBlock is returned.
  5845      Pressing ok without a selection is treated like cancel."
  5876      Pressing ok without a selection returns an empty collection."
  5846 
  5877 
  5847     ^ self
  5878     ^ self
  5848         choose:aString 
  5879         choose:aString 
  5849         fromList:list values:listValues 
  5880         fromList:list values:listValues 
  5850         buttons:buttonLabels values:buttonValues 
  5881         buttons:buttonLabels values:buttonValues 
  5887      from listValues is returned (doubleclick works as well). 
  5918      from listValues is returned (doubleclick works as well). 
  5888      The list may be suppressed (if the list arg is nil).
  5919      The list may be suppressed (if the list arg is nil).
  5889      Below the list, an optional row of buttons is shown, which can also be
  5920      Below the list, an optional row of buttons is shown, which can also be
  5890      clicked upon, and a corresponding value from buttonValues is returned.
  5921      clicked upon, and a corresponding value from buttonValues is returned.
  5891      If cancel is pressed, the value of cancelBlock is returned.
  5922      If cancel is pressed, the value of cancelBlock is returned.
  5892      Pressing ok without a selection is treated like cancel."
  5923      Pressing ok without a selection returns an empty collection."
  5893 
  5924 
  5894     ^ self
  5925     ^ self
  5895         choose:aString 
  5926         choose:aString 
  5896         fromList:list values:listValues 
  5927         fromList:list values:listValues 
  5897         initialSelection:initialListSelectionOrNil
  5928         initialSelection:initialListSelectionOrNil
  9921 ! !
  9952 ! !
  9922 
  9953 
  9923 !DialogBox class methodsFor:'documentation'!
  9954 !DialogBox class methodsFor:'documentation'!
  9924 
  9955 
  9925 version
  9956 version
  9926     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.339 2013-07-04 11:56:11 cg Exp $'
  9957     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.340 2013-07-05 12:25:14 cg Exp $'
  9927 !
  9958 !
  9928 
  9959 
  9929 version_CVS
  9960 version_CVS
  9930     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.339 2013-07-04 11:56:11 cg Exp $'
  9961     ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.340 2013-07-05 12:25:14 cg Exp $'
  9931 ! !
  9962 ! !
  9932 
  9963 
  9933 
  9964 
  9934 DialogBox initialize!
  9965 DialogBox initialize!