Calypso question: adding a context menu item

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Calypso question: adding a context menu item

Juraj Kubelka
Hi,

To implement a context menu item. I have implemented a new class:

-=-=-=-
CmdCommand subclass: #ClyHelloCommand
        instanceVariableNames: ''
        classVariableNames: ''
        package: 'Calypso-Extensions’
-=-=-=-

with methods:

-=-=-=-=-
ClyHelloCommand class >> #systemBrowserMenuActivator
        <commandActivator>
       
        ^CmdContextMenuCommandActivator byRootGroupItemFor: ClyVariableSystemBrowserContext

ClyHelloCommand >> # defaultMenuItemName
        ^'Say Hello’

ClyHelloCommand >> # execute
        self inform: 'Hello'
-=-=-=-=-

But it does not display in the context menu. I expect it next to “Generate accessors” as I took this command as an example.
What do I miss?

Thanks,
Juraj
Reply | Threaded
Open this post in threaded view
|

Re: Calypso question: adding a context menu item

Denis Kudriashov
Hi Juraj.

I repeated your steps and it works for me:
In "vars" mode I have "Say Hello" in context menu of selected variable (just before "Show in method browser" item).

Maybe you were looking at context menu of class pane? In that case command activator should be defined as:
ClyHelloCommand class>>systemBrowserClassMenuActivator
        <commandActivator>
        ^CmdContextMenuCommandActivator byRootGroupItemFor: ClyClassSystemBrowserContext




2017-12-05 18:12 GMT+01:00 Juraj Kubelka <[hidden email]>:
Hi,

To implement a context menu item. I have implemented a new class:

-=-=-=-
CmdCommand subclass: #ClyHelloCommand
        instanceVariableNames: ''
        classVariableNames: ''
        package: 'Calypso-Extensions’
-=-=-=-

with methods:

-=-=-=-=-
ClyHelloCommand class >> #systemBrowserMenuActivator
        <commandActivator>

        ^CmdContextMenuCommandActivator byRootGroupItemFor: ClyVariableSystemBrowserContext

ClyHelloCommand >> # defaultMenuItemName
        ^'Say Hello’

ClyHelloCommand >> # execute
        self inform: 'Hello'
-=-=-=-=-

But it does not display in the context menu. I expect it next to “Generate accessors” as I took this command as an example.
What do I miss?

Thanks,
Juraj

Reply | Threaded
Open this post in threaded view
|

Re: Calypso question: adding a context menu item

Juraj Kubelka
Hi Denis,

Thanks! In dead, I used incorrect context.

Juraj

On Dec 5, 2017, at 18:22, Denis Kudriashov <[hidden email]> wrote:

Hi Juraj.

I repeated your steps and it works for me:
In "vars" mode I have "Say Hello" in context menu of selected variable (just before "Show in method browser" item).

Maybe you were looking at context menu of class pane? In that case command activator should be defined as:
ClyHelloCommand class>>systemBrowserClassMenuActivator
        <commandActivator>
        ^CmdContextMenuCommandActivator byRootGroupItemFor: ClyClassSystemBrowserContext




2017-12-05 18:12 GMT+01:00 Juraj Kubelka <[hidden email]>:
Hi,

To implement a context menu item. I have implemented a new class:

-=-=-=-
CmdCommand subclass: #ClyHelloCommand
        instanceVariableNames: ''
        classVariableNames: ''
        package: 'Calypso-Extensions’
-=-=-=-

with methods:

-=-=-=-=-
ClyHelloCommand class >> #systemBrowserMenuActivator
        <commandActivator>

        ^CmdContextMenuCommandActivator byRootGroupItemFor: ClyVariableSystemBrowserContext

ClyHelloCommand >> # defaultMenuItemName
        ^'Say Hello’

ClyHelloCommand >> # execute
        self inform: 'Hello'
-=-=-=-=-

But it does not display in the context menu. I expect it next to “Generate accessors” as I took this command as an example.
What do I miss?

Thanks,
Juraj


Reply | Threaded
Open this post in threaded view
|

Re: Calypso question: adding a context menu item

Sean P. DeNigris
Administrator
In reply to this post by Juraj Kubelka
Juraj Kubelka wrote
> To implement a context menu item

Just in case someone stumbles on this thread with a similar problem… Much
has changed in Calypso and dependencies, making this snippet obsolete. After
struggling to port to latest, API, the easiest way to find out how to do
this seems to be to dig down via Morphic halos into an existing Calypso
command that is close to what you want. More generally, one could browse
senders of #classAnnotation, the current pragma, but there are lots of
senders.



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Cheers,
Sean