New Macro Menu help
Posted by: Slayer
Date: June 20, 2009 08:03PM

Well, I was trying to create an option under the Edit menu but I couldn't.
#setmenu(<menuName>,<itemType>[,<itemName>[,<command>]][,<location>]);

myOption_BuildMenu{
setmenu( "Edit", popup, "myOption", 5);
}
$OnInit=$OnInit."myOption_BuildMenu;";
I need some help with this, can somebody provide me the right code to create an option called "myOption". It doesn't need to do anything. I'm just trying to understand how this works.
Thanks in advance.

Re: New Macro Menu help
Posted by: disrupted
Date: June 20, 2009 08:28PM

it should be &Edit


myOption{
alert("this is a test","test" ,INFO);
}

myOption_BuildMenu{
setmenu( "&Edit", popup, "myOption", 5);
}

$OnInit=$OnInit."myOption_BuildMenu;";
$macroModules=$macroModules."myOption_test;";


Re: New Macro Menu help
Posted by: Slayer
Date: June 20, 2009 09:24PM

Thanks for your reply. I have two questions:
What for is the '5' (4th parameter) in 'setmenu('? I just copied the line from another Macro.
And what about the line 'macroModules'.

Re: New Macro Menu help
Posted by: desga2
Date: June 20, 2009 10:13PM

If you read good the Macro Language documentation:
#setmenu(<menuName>,<itemType>[,<itemName>[,<command>]][,<location>]);
The '5' (4th parameter) is referer to <location>, this is the new item/entry possition in menu. (first is zero (0) and the default value is last (-1))

Line "macroModules" add your macro file/module to the list of macros in the Macro Extension panel in Preferences. This allow to user disable it.

I don't know why but we forget documented it.

Edited: Now already documented.

K-Meleon in Spanish



Edited 3 time(s). Last edit at 06/20/2009 11:07PM by desga2.

Re: New Macro Menu help
Posted by: Slayer
Date: June 20, 2009 10:43PM

Thanks desga, I've read some of the Docs, but they somewhat dispersed, and I could not find simple examples on using this Macro language. Just definitions.
It would be great also if someone provides me a link with all those Global Variables that are part of the KM Interface. ie:_Config_General
This line is from the flashswitch file
setmenu("_Config_General",popup,"Flash Switcher",5);
Where I can find what '_Config_General' means, I know that is the menu, but where are those definitions?
BTW: I can not make to work the dummy 'myOption' option. Do I need to change the &Edit to &Editor? The file appears in my list of Macros.

Thanks again everybody.

Re: New Macro Menu help
Posted by: desga2
Date: June 20, 2009 11:21PM

Quote
Slayer
It would be great also if someone provides me a link with all those Global Variables that are part of the KM Interface. ie:_Config_General
This line is from the flashswitch file
setmenu("_Config_General",popup,"Flash Switcher",5);
Where I can find what '_Config_General' means, I know that is the menu, but where are those definitions?
BTW: I can not make to work the dummy 'myOption' option. Do I need to change the &Edit to &Editor? The file appears in my list of Macros.

All default menus are defined in menus.cfg file that you can found in K-Meleon\defaults\settings folder. Read about menus.cfg in config files documentation.

In this case '_Config_General' is like above case the menu name, but in this case this seems a macro defined menu (not a default menu name). Above this line in the code you must find other setmenu() line to define '_Config_General' menu.

setmenu("_Config_General",popup,"Flash Switcher",5);
Define a popup menu named "Flash Switcher" in the menu named "_Config_General".

All default menu names are defined in english (translations are transparent).
"&Edit" is the "Edit" (Editar) menu for all localizations in macros but is showed translated in GUI menu. By this way your macro work in all localizations.

K-Meleon in Spanish



Edited 2 time(s). Last edit at 06/20/2009 11:28PM by desga2.

Re: New Macro Menu help
Posted by: disrupted
Date: June 20, 2009 11:40PM


i think the toolbar images at the bottom of the wiki are a little bit out of date.
ie toolbar=ie
kmeleon default toolbar= also ie tongue sticking out smiley

kinda reminds me of this review: (check the snapshots on the right)
http://www.linux.com/archive/feature/44667
all your geckos are belong to kmeleon! grinning smiley

Re: New Macro Menu help
Posted by: Slayer
Date: June 20, 2009 11:44PM

Hey cool:
#setmenu(<menuName>,<itemType>[,<itemName>[,<command>]][,<location>]);

myOption{
alert("this is a test","test" ,INFO);
}

myOption_BuildMenu{
setmenu( "&Edit", macro, "myOption",myOption, -1);
}

$OnInit=$OnInit."myOption_BuildMenu;";
$macroModules=$macroModules."myOption;";

I used 'macro' as a 2nd parameter in function 'setmenu'. I don't know if that is correct, but the code works.smiling smiley

Re: New Macro Menu help
Posted by: Slayer
Date: June 20, 2009 11:51PM

Better:
#setmenu(<menuName>,<itemType>[,<itemName>[,<command>]][,<location>]);

myOption{
alert("this is a test","test" ,INFO);
}

myOption_BuildMenu{
setmenu("&Edit",popup,"Hey",-1);
setmenu( "Hey", macro, "myOption",myOption, -1);
}

$OnInit=$OnInit."myOption_BuildMenu;";
$macroModules=$macroModules."myOption;";


Re: New Macro Menu help
Posted by: desga2
Date: June 20, 2009 11:55PM

Quote
Slayer
I used 'macro' as a 2nd parameter in function 'setmenu'. I don't know if that is correct, but the code works.smiling smiley

Yes it's, "macro" is for macro called, "popup" is for create a submenu in a menu.
You need read again the documentation about setmenu() macro function.
MacroLanguage
MacroLanguage2
K-Meleon Macro Language (external by kko)

@ disrupted:
K-Meleon is the begining of all browser. tongue sticking out smiley

K-Meleon in Spanish



Edited 2 time(s). Last edit at 06/21/2009 12:01AM by desga2.

Re: New Macro Menu help
Posted by: guenter
Date: June 21, 2009 12:08PM

Quote
disrupted
kmeleon default toolbar= also ie tongue sticking out smiley

K-Meleon comes from an MFC based IEembed example for VC6. grinning smiley

This was later used by Mozilla project. You can still find

./Mozilla/embedding/tests/mfcembed/Mfcembed.cpp


K-Meleon/src/Mfcembed.cpp the name is still used smiling smiley



Edited 1 time(s). Last edit at 06/21/2009 12:16PM by guenter.

Re: New Macro Menu help
Posted by: kko
Date: June 21, 2009 07:36PM

Quote
desga2
Line "macroModules" add your macro file/module to the list of macros in the Macro Extension panel in Preferences. This allow to user disable it.

No, that's wrong. It has nothing to do with the preferences panel. It's for macros only.

Quote
desga2
I don't know why but we forget documented it.

No, it's documented in the Macro Coding Guidelines.

Quote
desga2
Edited: Now already documented.

Removed. This is not a feature of the macro language itself, it's just a feature of the framework provided by the default macros.

Re: New Macro Menu help
Posted by: desga2
Date: June 21, 2009 09:11PM

OK, I'm sorry, I didn't remember Macro Coding Guidelines.

K-Meleon in Spanish



Edited 1 time(s). Last edit at 06/21/2009 09:11PM by desga2.

Re: New Macro Menu help
Posted by: Slayer
Date: June 21, 2009 10:50PM

I'm must be doing something wrong, please help me:

myOption{
alert("this is a test","test" ,INFO);
}

myOption_BuildMenu{
setmenu("&Edit",popup,"Hey",-1);
setmenu( "Hey", macro, "Option1",myOption, -1);
setmenu( "Hey", macro, "Option2",myOption, -1);
setmenu( "Hey", macro, "Option3",myOption, -1);
setmenu( "Hey", macro, "Option4",myOption, -1);

}

$OnInit=$OnInit."myOption_BuildMenu;";
$macroModules=$macroModules."myOption;";
I was trying to get different options, but all of them do the same Alert. I only get 'option4'

Thanks.

Re: New Macro Menu help
Posted by: Slayer
Date: June 21, 2009 10:56PM

Add:
I want all the options to trigger the same Alert. But I only get one 'option' menu.

Re: New Macro Menu help
Posted by: JamesD
Date: June 21, 2009 11:52PM

@ Slayer

I don't think the macro language likes it when you have multiple items calling the same macro. I added three more and it seems to work.

_myOption1{
alert("this is a test1","test" ,INFO);
}

_myOption2{
alert("this is a test2","test" ,INFO);
}

_myOption3{
alert("this is a test3","test" ,INFO);
}

_myOption4{
alert("this is a test4","test" ,INFO);
}
myOption_BuildMenu{
setmenu("&Edit",popup,"Hey",-1);
setmenu( "Hey", macro, "Option1", _myOption1, 1);
setmenu( "Hey", macro, "Option2", _myOption2, 2);
setmenu( "Hey", macro, "Option3", _myOption3, 0);
setmenu( "Hey", macro, "Option4", _myOption4, 3);

}

$OnInit=$OnInit."myOption_BuildMenu;";
$macroModules=$macroModules."myOption;";


Re: New Macro Menu help
Posted by: desga2
Date: June 22, 2009 03:34PM

Menus and buttons are diferenced by K-Meleon to command/macro (not by name), if K-Meleon macro found some button/menus items with identical command/macro for K-Meleon maro are the same button/menu entry and only one is showed.
(K-Meleon considered that duplicated is stupid and I too) tongue sticking out smiley

K-Meleon in Spanish



Edited 2 time(s). Last edit at 06/22/2009 03:35PM by desga2.

Re: New Macro Menu help
Posted by: Slayer
Date: June 22, 2009 04:48PM

Quote
desga2
Menus and buttons are diferenced by K-Meleon to command/macro (not by name), if K-Meleon macro found some button/menus items with identical command/macro for K-Meleon maro are the same button/menu entry and only one is showed.
(K-Meleon considered that duplicated is stupid and I too) tongue sticking out smiley
My original idea was not to trigger the same command, but reducing the code, using a loop. Since all the menus were calling a similar Procedure.

Re: New Macro Menu help
Posted by: JamesD
Date: June 22, 2009 05:25PM

Quote
Slayer
My original idea was not to trigger the same command, but reducing the code, using a loop. Since all the menus were calling a similar Procedure.

This code uses the $ARG statement. The code is smaller. You can make choice of what action to take based on value of $_opt.

_myOption{
$_opt = $ARG ;
alert("This is the choice. " .$_opt, "test", INFO);
}

myOption_BuildMenu{
setmenu("&Edit",popup,"Hey",-1);
setmenu( "Hey","macro","Option1","_myOption(1)");
setmenu( "Hey","macro","Option2","_myOption(2)");
setmenu( "Hey","macro","Option3","_myOption(3)");
setmenu( "Hey","macro","Option4","_myOption(4)");
}

$OnInit=$OnInit."myOption_BuildMenu;";
$macroModules=$macroModules."myOption;";


Re: New Macro Menu help
Posted by: Slayer
Date: June 22, 2009 07:59PM

Quote
JamesD
This code uses the $ARG statement. The code is smaller. You can make choice of what action to take based on value of $_opt.

_myOption{
$_opt = $ARG ;
alert("This is the choice. " .$_opt, "test", INFO);
}

myOption_BuildMenu{
setmenu("&Edit",popup,"Hey",-1);
setmenu( "Hey","macro","Option1","_myOption(1)");
setmenu( "Hey","macro","Option2","_myOption(2)");
setmenu( "Hey","macro","Option3","_myOption(3)");
setmenu( "Hey","macro","Option4","_myOption(4)");
}

$OnInit=$OnInit."myOption_BuildMenu;";
$macroModules=$macroModules."myOption;";
That's excellent! Thanks. Is like working with arrays.
:cool:

K-Meleon forum is powered by Phorum.