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 |