Here is what I did (2 classes) Then, you can do: === menu := MenuMorphNG new. menu add: 'test1' value: #testForPharo. menu addLine. menu add: 'test2' value: 2.0. menu localize; invokeModal. menu selectedValue === Jannik On Mar 11, 2013, at 10:09 PM, stephane ducasse <stephane.ducasse@free.fr> wrote:
I should probably redefine
invokeWithEvent: evt "Perform the action associated with the given menu item."
| w | self isEnabled ifFalse: [^ self]. target class == HandMorph ifTrue: [(self notObsolete) ifFalse: [^ self]]. owner ifNotNil:[self isStayUpItem ifFalse:[ self flag: #workAround. "The tile system invokes menus straightforwardly so the menu might not be in the world." (w := self world) ifNotNil:[ owner deleteIfPopUp: evt. "Repair damage before invoking the action for better feedback" w displayWorldSafely]]]. selector ifNil:[^self]. Cursor normal showWhile: [ | selArgCount | "show cursor in case item opens a new MVC window" (selArgCount := selector numArgs) = 0 ifTrue: [target perform: selector] ifFalse: [selArgCount = arguments size ifTrue: [target perform: selector withArguments: arguments] ifFalse: [target perform: selector withArguments: (arguments copyWith: evt)]]. self changed].
On Mar 11, 2013, at 10:06 PM, stephane ducasse <stephane.ducasse@free.fr> wrote:
Now I have the problem that I do not know how to get the value from the menu and not the menu item morph
setFFTSize "Set the size of the FFT used for frequency analysis."
| 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 value: r]. sz := aMenu xxxxxxx
sz ifNil: [^ self]. on := soundInput isRecording. self stop. fft := FFT new: sz. self resetDisplay. on ifTrue: [self start].
do you have an idea?
Stef