Re: [Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-08 Thread Juraj Kubelka
Thanks to all answers! It finally works. :-) 
I am not sure where I did a mistake before.

Juraj

> On Feb 8, 2018, at 05:33, Stephan Eggermont  wrote:
> 
> And your original question
> 
> morph := 'Hello' asMorph.
> colorBlock := [ :colorName |
>  morph color: (Color perform: colorName)].
> morph on: #mouseUp send: value to: [ |menu|
>  menu := MenuMorph new.
>  menu add: 'orange' target: colorBlock selector: #value: argument:
> #orange.
>  menu add: 'blue' target: colorBlock selector: #value: argument:
> #blue.
>  menu popUpInWorld].
> morph openInWindow
> 
> 




Re: [Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-08 Thread Stephan Eggermont
And your original question

morph := 'Hello' asMorph.
colorBlock := [ :colorName |
  morph color: (Color perform: colorName)].
morph on: #mouseUp send: value to: [ |menu|
  menu := MenuMorph new.
  menu add: 'orange' target: colorBlock selector: #value: argument:
#orange.
  menu add: 'blue' target: colorBlock selector: #value: argument:
#blue.
  menu popUpInWorld].
morph openInWindow




Re: [Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-07 Thread Sven Van Caekenberghe


> On 8 Feb 2018, at 08:16, Stephan Eggermont  wrote:
> 
> Juraj Kubelka 
> wrote:
>> I am not sure if we understand each other. 
>> The example: 
>> 
>> morph := 'Hello' asMorph.
>> morph on: #mouseUp send: #traceCr: to: morph.
>> morph openInWindow
>> 
>> does not work for me. Actually I have not found a code that triggers
>> #mouseUp event neither.
> 
> Well, it works for me on 60528 on Windows. Did you open the transcript
> window before running the example?
> 
> Stephan

Works fine for me in Pharo 7.

You do click, do you ?

Her is a variation:

morph := 'Click me' asMorph.
morph on: #mouseUp send: #value to: [ self inform: 'You clicked me!' ].
morph openInWindow.




Re: [Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-07 Thread Stephan Eggermont
Juraj Kubelka 
wrote:
> I am not sure if we understand each other. 
> The example: 
> 
> morph := 'Hello' asMorph.
> morph on: #mouseUp send: #traceCr: to: morph.
> morph openInWindow
> 
> does not work for me. Actually I have not found a code that triggers
> #mouseUp event neither.

Well, it works for me on 60528 on Windows. Did you open the transcript
window before running the example?

Stephan






Re: [Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-07 Thread Juraj Kubelka
Hi Stephan,

> El 05-02-2018, a las 11:27, Stephan Eggermont  escribió:
> 
> Juraj Kubelka 
> wrote:
>>> morph := 'Hello' asMorph.
>>> morph on: #mouseUp send: #traceCr: to: morph.
>>> morph openInWindow.
>>> 
>> 
>> This does not work for me either. 
>> I am fine with the MorphicEventHandler solution.
> 
> Not at all? Or do you just need to use the variant sending #value: to a
> block with the morph as an argument?

I am not sure if we understand each other. 
The example: 

morph := 'Hello' asMorph.
morph on: #mouseUp send: #traceCr: to: morph.
morph openInWindow

does not work for me. Actually I have not found a code that triggers #mouseUp 
event neither.

The example:

morph := 'Hello' asMorph.
morph eventHandler: MorphicEventHandler new.
morph eventHandler
on: #click send: #traceCr: to: morph.
morph openInWindow.

works well and this is what I use.

All tested on Pharo 6.1. 

Cheers,
Juraj

> 
> Stephan
> 
> 
> 




Re: [Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-05 Thread Stephan Eggermont
Juraj Kubelka 
wrote:
>> morph := 'Hello' asMorph.
>> morph on: #mouseUp send: #traceCr: to: morph.
>> morph openInWindow.
>> 
> 
> This does not work for me either. 
> I am fine with the MorphicEventHandler solution.

Not at all? Or do you just need to use the variant sending #value: to a
block with the morph as an argument?

Stephan





Re: [Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-05 Thread Juraj Kubelka


> El 03-02-2018, a las 07:26, stephan  escribió:
> 
> On 02-02-18 15:19, Juraj Kubelka wrote:
>> Thank you Stephan!
>> There is my exercise:
>> “when:send:to"
>> morph := 'Hello' asMorph.
>> morph when: #click send: #traceCr: to: morph.
>> morph openInWindow.
> 
> Sorry
> 
> morph := 'Hello' asMorph.
> morph on: #mouseUp send: #traceCr: to: morph.
> morph openInWindow.
> 

This does not work for me either. 
I am fine with the MorphicEventHandler solution.

Thanks!
Juraj


Re: [Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-03 Thread stephan

On 02-02-18 15:19, Juraj Kubelka wrote:

Thank you Stephan!

There is my exercise:

“when:send:to"
morph := 'Hello' asMorph.
morph when: #click send: #traceCr: to: morph.
morph openInWindow.


Sorry

morph := 'Hello' asMorph.
morph on: #mouseUp send: #traceCr: to: morph.
morph openInWindow.




Re: [Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-02 Thread Juraj Kubelka
Thank you Stephan!

There is my exercise: 

“when:send:to"
morph := 'Hello' asMorph.
morph when: #click send: #traceCr: to: morph.
morph openInWindow.

—> it does not work for me. I do not know what the announcement should be

"Handler"
morph := 'Hello' asMorph.
morph eventHandler: MorphicEventHandler new.
morph eventHandler
on: #click send: #traceCr: to: morph.
morph openInWindow.

—> It works and there are examples in MorphicEventHandlerTest

Thanks!

> El 02-02-2018, a las 03:43, Stephan Eggermont  escribió:
> 
> Juraj Kubelka 
> wrote:
>> Let’s say that we have a StringMorph: ‘Hello' asMorph.
>> Can I attach a MenuMorph (or a menu building logic) and display the
>> context menu on a mouse click in the StringMorph? 
>> 
>> Or the only way to do it is to subclass the StringMorph and write the
>> logic in the #mouseDown: method? 
> 
> #when:send:to:, or replace the eventhandler, or subclass
> 
> Stephan
> 
> 
> 




Re: [Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-01 Thread Stephan Eggermont
Juraj Kubelka 
wrote:
> Let’s say that we have a StringMorph: ‘Hello' asMorph.
> Can I attach a MenuMorph (or a menu building logic) and display the
> context menu on a mouse click in the StringMorph? 
> 
> Or the only way to do it is to subclass the StringMorph and write the
> logic in the #mouseDown: method? 

#when:send:to:, or replace the eventhandler, or subclass

Stephan





[Pharo-users] How can a Morph display a context menu on a mouse click?

2018-02-01 Thread Juraj Kubelka
Hi, 

Let’s say that we have a StringMorph: ‘Hello' asMorph.
Can I attach a MenuMorph (or a menu building logic) and display the context 
menu on a mouse click in the StringMorph? 

Or the only way to do it is to subclass the StringMorph and write the logic in 
the #mouseDown: method? 

Thanks!
Juraj