On Mar 11, 2013, at 5:41 PM, stephane ducasse <[email protected]> wrote:


On Mar 11, 2013, at 2:10 PM, jannik laval <[email protected]> wrote:

Hi Stef,

I am searching to do that too.
For now, I am using something else... And I plan to create new Menu more usable.

Here is what I use, for your case, just adapt it when trying:

===
        | aMenu sz on |
on := soundInput isRecording.
        self stop.
        aMenu := MenuMorph new title: ('FFT size (currently {1})' translated format:{fft n}).
        ((7 to: 10) collect: [:n | 2 raisedTo: n]) do: [:r | 
aMenu add: r printString 
target: FFT
selector: #new
argument: r
].

        aMenu popUpInWorld.
        
        self resetDisplay.
        on ifTrue: [self start].
===

the problem is that we are missing a way to have menu that simply return a value (without resorting to a method execution and selector).

Yes, I know :)
Try this small class. I named it MenuMorphNG.
You can use it like that:

===
menu := MenuMorphNG new defaultTarget: menu.
menu add: 'test1' value: #testForPharo.
menu addLine.
menu add: 'test2' value: 2.0.
menu localize; invokeModal.
menu selectedValue
===

Jannik

Attachment: MenuMorphNG.st
Description: Binary data



Stef

Jannik


2013/3/11 stephane ducasse <[email protected]>
In fact I see that the problem is more into

how can I specify a menu item which returns a value that I specify without passing a symbol

                ((7 to: 10) collect: [:n | 2 raisedTo: n]) do: [:r | aMenu add: r printString action: r].


On Mar 11, 2013, at 1:28 PM, Stéphane Ducasse <[email protected]> wrote:

> HI guys
>
> I'm trying to fix all the sound interface for 2.0 and I got trapped into MenuMorph. How do I schedule a menu and get its selected value?
> I have to convert code like the following one.
>
>
>
>       | aMenu sz on |
>       aMenu := MenuMorph new title: ('FFT size (currently {1})' translated format:{fft n}).
>       ((7 to: 10) collect: [:n | 2 raisedTo: n]) do: [:r | aMenu add: r printString action: r].
>
>       sz := aMenu popUpInWorld.
>       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>               how can I get the selected value?
>
>
>       sz ifNil: [^ self].
>       on := soundInput isRecording.
>       self stop.
>       fft := FFT new: sz.
>       self resetDisplay.
>       on ifTrue: [self start].
>
>





--

~~Dr. Jannik Laval~~
École des Mines de Douai
Enseignant-chercheur
http://www.jannik-laval.eu



Reply via email to