Re: Adding to the menu?

From: Angel Ortega <angel_triptico.com>
Date: Thu, 6 Sep 2007 22:53:29 +0200
On Thu, Sep 06, 2007 at 01:47:05PM -0400, Jeremy Cowgar wrote:
> How can I add to the menu? I see that I can probably copy the existing menu 
> out of mp_core, but is there a way I can just add to it instead of 
> redefining the whole thing?

It's not necessary to redefine it. As the menu is a MPSL array, you can
just add things to it by using MPSL array manipulation functions. For
example, to add a separator to the first menu bar (the 'File' one), just
do

	push(mp.menu[0][1], '-');

This means "push the '-' string to the end of the second element of the
first element of mp.menu". The array mp.menu contains the dropdown menus;
each element is an array of two elements, the first one being the name of
the menu ("File", in the first one), and the second one is another array,
containing a list of actions. This is the list where we are adding the
separator.

If you just add that to your .mp.mpsl, there is nothing more to do. But If
you execute that command from the GUI, you must force a menu rebuild by
calling mp.update_ui() or your menu won't change.

You have another example of manipulating the menu here:

	http://lists.triptico.com/mp/0038.html

If you want to add your own functions to the menu, you must create actions
for them and add that to the menu.

If your function is my_utility(), you can create an action for it by
writing the following:

	mp.actions.my_utility = my_utility;
	mp.actdesc.my_utility = "My very useful function";

And then add 'my_utility' to the menu.

This custom functions probably belong better to a new dropdown menu, that
can be called 'Custom'. Create it by doing:

	push(mp.menu, [ "&Custom", [ 'my_utility', 'my_utility2' ] ]);

Happy hacking!

-- 
Angel Ortega
http://www.triptico.com



-- 
To unsubscribe, send mail to mp-unsubscribe_lists.triptico.com.


Received on Thu Sep 06 2007 - 22:55:11 CEST

This archive was generated by hypermail 2.2.0 : Thu Apr 10 2008 - 08:59:26 CEST