Author Topic: Adding a command to a context menu  (Read 5618 times)

dorza

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Adding a command to a context menu
« on: August 03, 2010, 11:26:11 AM »
Hello,

I would to add a command to _ext_menu_default which will do a certain action (search the web) with the word under the cursor.
I have written the command and it works great.

My problem is that I want it to be similar to "Go to definition of" command, meaning that if the word under cursor is "print" it will say in the context menu "Search the web for print" (like it will say "Go to definition of print").

How do I achieve such a behavior?

Thanks in advance

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Adding a command to a context menu
« Reply #1 on: August 03, 2010, 01:20:20 PM »
Have a look at the function _OnUpdate_push_ref in tags.e - it's called by _OnUpdate_push_tag.  It calls _menu_set_state to update the menu if the menu item has push_tag as its command.

Hence if your command is called my_command, you need to write an _OnUpdate_my_command function to modify the menu.  Your on-update function should return MF_ENABLED if the menu item should be enabled.

Graeme

dorza

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Adding a command to a context menu
« Reply #2 on: August 04, 2010, 11:02:30 AM »
Thanks! worked like a charm.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Adding a command to a context menu
« Reply #3 on: August 04, 2010, 11:50:21 AM »
I just remembered that chrisant posted this
http://community.slickedit.com/index.php?topic=5036.0
which seems similar to what you've done.