In fact I did not add an instance method because we always have to invoke the
menu invokeAt: ActiveHand position in: ActiveWorld allowKeyboard: true.
So in that case I prefer to use chooseFrom:
But indeed this is a good experience and probably we should rebuild menu and
menuItem
one of these days. I think that cleaning again a bit more is needed. I added
some entries in fogbugz for that.
Stef
On Mar 12, 2013, at 4:23 PM, stephane ducasse <[email protected]> wrote:
> Jannik
>
> I'm studying right now choose…
> So I think that I will add a method add: value: to the instance side to see
> how it look like.
>
> Stef
>
>
> chooseFrom: aList lines: linesArray title: queryString
> "Choose an item from the given list. Answer the index of the selected
> item."
> "MenuMorph
> chooseFrom: #('Hello' 'Pharoers' 'Here' 'We' 'Go')
> lines: #(2 4)
> title: 'What''s up?'"
>
> | menu result |
> (ProvideAnswerNotification signal: queryString) ifNotNil:[:answer |
> 1 to: aList size do:[:i| (aList at: i) = answer ifTrue:[^i]].
> ^0].
> result := 0.
> menu := self new.
> menu addTitle: queryString.
> 1 to: aList size do:[:i|
> menu add: (aList at: i) asString target: [:v| result := v]
> selector: #value: argument: i.
> (linesArray includes: i) ifTrue: [menu addLine]].
>
> menu invokeAt: ActiveHand position in: ActiveWorld allowKeyboard: true.
> ^result