PopUpMenu.st
changeset 3965 9a999e1c9e5e
parent 3913 f15213240dde
child 3972 810842932c33
equal deleted inserted replaced
3964:f272bb5029f0 3965:9a999e1c9e5e
    52     Static definition makes sense, if the menu stays constant and you want to
    52     Static definition makes sense, if the menu stays constant and you want to
    53     assign it once for the lifetime of the view.
    53     assign it once for the lifetime of the view.
    54 
    54 
    55     Dynamic menus are easier to use, if the number of or look of the entries has to
    55     Dynamic menus are easier to use, if the number of or look of the entries has to
    56     change according the internal state of some model. Also, this is the ST-80 way
    56     change according the internal state of some model. Also, this is the ST-80 way
    57     of using popupMenus. For dynamic popups, the views model is asked for a menu
    57     of using popupMenus. For dynamic popups, the view's model is asked for a menu
    58     via the #menuSelector each time a button press occurs.
    58     via the #menuSelector each time a button press occurs.
    59 
    59 
    60     See examples section for more.
    60     See examples section for more.
    61 
    61 
    62     [author:]
    62     [author:]
   989      or - if no values where specified - return the index.
   989      or - if no values where specified - return the index.
   990      If nothing was selected, return 0.
   990      If nothing was selected, return 0.
   991      Modal - i.e. stay in the menu until finished.
   991      Modal - i.e. stay in the menu until finished.
   992      This is the ST-80 way of launching a menu."
   992      This is the ST-80 way of launching a menu."
   993 
   993 
       
   994     |vector|
       
   995 
   994     defaultHideOnRelease := false.
   996     defaultHideOnRelease := false.
   995     menuView labels notNil ifTrue:[
   997     (vector := menuView labels) notNil ifTrue:[
   996         menuView labels:(Array with:aString with:'=') , menuView labels.
   998         menuView labels:(Array with:aString
   997     ].
   999                                with:'=') , vector.
   998     menuView selectors notNil ifTrue:[
  1000     ].
   999         menuView selectors:(Array with:nil with:nil) , menuView selectors.
  1001     (vector := menuView selectors) notNil ifTrue:[
  1000     ].
  1002         menuView selectors:#(nil nil) , vector.
  1001 "/    menuView disable:1; disable:2.
  1003     ].
       
  1004     (vector := menuView args) notNil ifTrue:[
       
  1005         menuView args:#(nil nil) , vector.
       
  1006     ].
       
  1007     (vector := menuView checkFlags) notNil ifTrue:[
       
  1008         menuView checkFlags:#(nil nil) , vector.
       
  1009     ].
       
  1010     (vector := menuView actions) notNil ifTrue:[
       
  1011         menuView actions:#(nil nil) , vector.
       
  1012     ].
       
  1013     menuView disable:1; disable:2.
  1002 
  1014 
  1003     ^ self startUp.
  1015     ^ self startUp.
  1004 
  1016 
  1005     "
  1017     "
  1006      (PopUpMenu
  1018      (PopUpMenu
  1065 	^ actionLabels asStringCollection
  1077 	^ actionLabels asStringCollection
  1066     ].
  1078     ].
  1067     ^ menuView list
  1079     ^ menuView list
  1068 !
  1080 !
  1069 
  1081 
  1070 labels:labelString lines:lineArray values:valueArray
  1082 labels:labelString lines:lineArrayArg values:valueArray
  1071     "define the menu the ST-80 way (with labels and lines defined separately)"
  1083     "define the menu the ST-80 way (with labels and lines defined separately)"
  1072 
  1084 
  1073     |labelArray argArray convertedLabels 
  1085     |lineArray labelArray argArray convertedLabels 
  1074      offs dstOffs linePos m|
  1086      offs dstOffs linePos m|
       
  1087 
       
  1088     lineArray := lineArrayArg.
       
  1089     lineArray first == 0 ifTrue:[
       
  1090         lineArray := lineArray copyFrom:2.
       
  1091     ].
  1075 
  1092 
  1076     actionLabels := labelString.
  1093     actionLabels := labelString.
  1077     actionLines := lineArray.
  1094     actionLines := lineArray.
  1078     actionValues := valueArray.
  1095     actionValues := valueArray.
  1079 
  1096 
  1605 ! !
  1622 ! !
  1606 
  1623 
  1607 !PopUpMenu class methodsFor:'documentation'!
  1624 !PopUpMenu class methodsFor:'documentation'!
  1608 
  1625 
  1609 version
  1626 version
  1610     ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.101 2009-09-15 18:20:09 cg Exp $'
  1627     ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.102 2009-10-12 10:10:05 cg Exp $'
       
  1628 !
       
  1629 
       
  1630 version_CVS
       
  1631     ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.102 2009-10-12 10:10:05 cg Exp $'
  1611 ! !
  1632 ! !