#DOCUMENTATION by cg
class: Menu
added: #itemAtValue:
comment/format in:
#detectItem:ifNone:
#menuItemAt:
#valueAt:
#valueAt:put:
#values:
--- a/Menu.st Mon Mar 13 09:54:33 2017 +0100
+++ b/Menu.st Tue Mar 14 20:31:05 2017 +0100
@@ -265,6 +265,14 @@
groupSizes := something.
!
+itemAtValue:aValue
+ "gets the item which has aValue assigned as value
+ "
+ ^ self menuAndSubmenusDetectItem:[:anItem | anItem value == aValue ].
+
+ "Created: / 14-03-2017 / 16:12:37 / cg"
+!
+
items
^ items
!
@@ -336,8 +344,8 @@
!
menuItemAt:index
- "gets the menu item at the given index. When the index is out of bounds
- nil is returned"
+ "gets the menu item at the given index.
+ When the index is out of bounds, nil is returned"
(index > 0 and:[ index <= items size ]) ifTrue:[
^ items at:index
@@ -345,6 +353,7 @@
^ nil
"Modified: / 30-06-2011 / 10:51:39 / cg"
+ "Modified (comment): / 14-03-2017 / 16:11:31 / cg"
!
menuItemLabeled:anItemLabel
@@ -488,19 +497,21 @@
!
valueAt:index
- "return a collection of values from my items"
+ "return the value of an item"
^ (items at:index) value
- "Created: 25.2.1997 / 19:49:41 / cg"
+ "Created: / 25-02-1997 / 19:49:41 / cg"
+ "Modified (comment): / 14-03-2017 / 16:10:23 / cg"
!
valueAt:anIndex put:aValue
- "put value an an index"
+ "put value at an index"
(items at:anIndex) value:aValue
- "Created: 6.3.1997 / 15:15:48 / cg"
+ "Created: / 06-03-1997 / 15:15:48 / cg"
+ "Modified (comment): / 14-03-2017 / 16:10:29 / cg"
!
values
@@ -512,7 +523,7 @@
!
values:aCollectionOfValues
- "return a collection of values from my items"
+ "set the collection of values in my items"
|s|
@@ -527,7 +538,8 @@
self error:'not enough elements in the value collection' mayProceed:true
]
- "Created: / 27.10.1997 / 15:15:47 / cg"
+ "Created: / 27-10-1997 / 15:15:47 / cg"
+ "Modified (comment): / 14-03-2017 / 16:10:41 / cg"
!
visibleMenuItemGroups
@@ -1022,17 +1034,18 @@
!
-detectItem:aBlock ifNone:exceptionBlock
+detectItem:aBlock ifNone:exceptionValue
"evaluate the argument, aBlock for each item in the menu until the
block returns true; in this case return the item which caused the
true evaluation.
- If none of the evaluations returns true, return the result of the
- evaluation of the exceptionBlock
+ If none of the evaluations returns true, return the value from exceptionValue
"
items notNil ifTrue:[
- ^ items detect:aBlock ifNone:exceptionBlock
+ ^ items detect:aBlock ifNone:exceptionValue
].
- ^ exceptionBlock value
+ ^ exceptionValue value
+
+ "Modified (comment): / 14-03-2017 / 16:09:51 / cg"
!
itemsDo:aOneArgBlock