PullDownMenu.st
changeset 6101 c71ff456e7ad
parent 6057 e3929e2b5edf
child 6169 80aa1b240a75
equal deleted inserted replaced
6100:43667474ed53 6101:c71ff456e7ad
  1195      handle CursorLeft/Right for non-mouse operation
  1195      handle CursorLeft/Right for non-mouse operation
  1196      (for example, if it has the explicit focus)
  1196      (for example, if it has the explicit focus)
  1197      These will pull the previous/next menu
  1197      These will pull the previous/next menu
  1198     "
  1198     "
  1199     ((key == #CursorRight) or:[key == #CursorLeft]) ifTrue:[
  1199     ((key == #CursorRight) or:[key == #CursorLeft]) ifTrue:[
  1200 	activeMenuNumber isNil ifTrue:[
  1200         activeMenuNumber isNil ifTrue:[
  1201 	    index := (key == #CursorRight) ifTrue:[1] ifFalse:[menus size].
  1201             index := (key == #CursorRight) ifTrue:[1] ifFalse:[menus size].
  1202 	] ifFalse:[
  1202         ] ifFalse:[
  1203 	    (key == #CursorRight) ifTrue:[
  1203             (key == #CursorRight) ifTrue:[
  1204 		"/ if its a cursor-right, and the current item
  1204                 "/ if it's a cursor-right, and the current item
  1205 		"/ has a submenu, then pop up the submenu
  1205                 "/ has a submenu, then pop up the submenu
  1206 		m := menus at:activeMenuNumber.
  1206                 m := menus at:activeMenuNumber.
  1207 		m notNil ifTrue:[
  1207                 m notNil ifTrue:[
  1208 		    m selectedItemHasSubmenu ifTrue:[
  1208                     m selectedItemHasSubmenu ifTrue:[
  1209 			m showSubmenu:(m selection).
  1209                         m showSubmenu:(m selection).
  1210 			^ self.
  1210                         ^ self.
  1211 		    ].
  1211                     ].
  1212 		].
  1212                 ].
  1213 	    ].
  1213             ].
  1214 
  1214 
  1215 	    (key == #CursorRight) ifTrue:[
  1215             (key == #CursorRight) ifTrue:[
  1216 		index := activeMenuNumber+1
  1216                 index := activeMenuNumber+1
  1217 	    ] ifFalse:[
  1217             ] ifFalse:[
  1218 		index := activeMenuNumber-1
  1218                 index := activeMenuNumber-1
  1219 	    ].
  1219             ].
  1220 	    index == 0 ifTrue:[index := menus size]
  1220             index == 0 ifTrue:[index := menus size]
  1221 	    ifFalse:[
  1221             ifFalse:[
  1222 		index > menus size ifTrue:[index := 1]
  1222                 index > menus size ifTrue:[index := 1]
  1223 	    ]
  1223             ]
  1224 	].
  1224         ].
  1225 	self pullMenu:index.
  1225         self pullMenu:index.
  1226 	^ self
  1226         ^ self
  1227     ].
  1227     ].
  1228 
  1228 
  1229 "/    activeMenuNumber isNil ifTrue:[
  1229 "/    activeMenuNumber isNil ifTrue:[
  1230 	"/
  1230         "/
  1231 	"/ find an item starting with that alpha-key
  1231         "/ find an item starting with that alpha-key
  1232 	"/
  1232         "/
  1233 	key isCharacter ifTrue:[
  1233         key isCharacter ifTrue:[
  1234 	    (key isLetter) ifTrue:[
  1234             (key isLetter) ifTrue:[
  1235 		activeMenuNumber isNil ifTrue:[
  1235                 activeMenuNumber isNil ifTrue:[
  1236 		    startIndex := 1.
  1236                     startIndex := 1.
  1237 		] ifFalse:[
  1237                 ] ifFalse:[
  1238 		    startIndex := activeMenuNumber + 1
  1238                     startIndex := activeMenuNumber + 1
  1239 		].
  1239                 ].
  1240 		index := titles 
  1240                 index := titles 
  1241 			    findFirst:[:item | 
  1241                             findFirst:[:item | 
  1242 					    item isString
  1242                                             item isString
  1243 					    and:[(item startsWith:key asUppercase)
  1243                                             and:[(item startsWith:key asUppercase)
  1244 						 or:[item startsWith:key asLowercase]]]
  1244                                                  or:[item startsWith:key asLowercase]]]
  1245 			    startingAt:startIndex.
  1245                             startingAt:startIndex.
  1246 
  1246 
  1247 		(index == 0 and:[startIndex ~~ 1]) ifTrue:[
  1247                 (index == 0 and:[startIndex ~~ 1]) ifTrue:[
  1248 		    index := titles 
  1248                     index := titles 
  1249 				findFirst:[:item | 
  1249                                 findFirst:[:item | 
  1250 						item isString
  1250                                                 item isString
  1251 						and:[(item startsWith:key asUppercase)
  1251                                                 and:[(item startsWith:key asUppercase)
  1252 						     or:[item startsWith:key asLowercase]]]
  1252                                                      or:[item startsWith:key asLowercase]]]
  1253 				startingAt:1.
  1253                                 startingAt:1.
  1254 		].
  1254                 ].
  1255 
  1255 
  1256 		index ~~ 0 ifTrue:[
  1256                 index ~~ 0 ifTrue:[
  1257 		    self pullMenu:index.
  1257                     self pullMenu:index.
  1258 		].
  1258                 ].
  1259 		^ self
  1259                 ^ self
  1260 	    ]
  1260             ]
  1261 	].
  1261         ].
  1262 "/    ].
  1262 "/    ].
  1263 
  1263 
  1264     activeMenuNumber isNil ifTrue:[
  1264     activeMenuNumber isNil ifTrue:[
  1265 	^ super keyPress:key x:x y:y
  1265         ^ super keyPress:key x:x y:y
  1266     ].
  1266     ].
  1267 
  1267 
  1268     "
  1268     "
  1269      Return, space or the (virtual) MenuSelect key trigger
  1269      Return, space or the (virtual) MenuSelect key trigger
  1270      a menu entry (for non-submenu entries).
  1270      a menu entry (for non-submenu entries).
  1271      Otherwise, if we have a submenu open,
  1271      Otherwise, if we have a submenu open,
  1272      pass the key on to it ...
  1272      pass the key on to it ...
  1273     "
  1273     "
  1274     m := menus at:activeMenuNumber.
  1274     m := menus at:activeMenuNumber.
  1275     m isNil ifTrue:[
  1275     m isNil ifTrue:[
  1276 	(key == #Return 
  1276         (key == #Return 
  1277 	or:[key == #MenuSelect
  1277         or:[key == #MenuSelect
  1278 	or:[key == Character space]]) ifTrue:[
  1278         or:[key == Character space]]) ifTrue:[
  1279 	    self performSelectedAction.
  1279             self performSelectedAction.
  1280 	].
  1280         ].
  1281     ] ifFalse:[
  1281     ] ifFalse:[
  1282 	m keyPress:key x:0 y:0.
  1282         m keyPress:key x:0 y:0.
  1283     ].
  1283     ].
  1284 
  1284 
  1285     "Modified: 25.2.1997 / 23:38:15 / cg"
  1285     "Modified: / 25-02-1997 / 23:38:15 / cg"
       
  1286     "Modified (format): / 13-02-2017 / 20:29:32 / cg"
  1286 !
  1287 !
  1287 
  1288 
  1288 showNoFocus:explicit
  1289 showNoFocus:explicit
  1289     "when stepping focus, hide any active menu"
  1290     "when stepping focus, hide any active menu"
  1290 
  1291