General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Questions on pluginmsg(toolbars ...
Posted by: JamesD
Date: July 03, 2009 02:40PM

I am trying to understand the format of the pluginmsg(toolbars... functions. I have some code running with the "COMMAND" in the code but I wish to have the "COMMAND" come from a variable. I had that work where "COMMAND" was a Command ID, but now I am trying to use a macro. I have an alert to show me the value in $_KS_Command and it looks the same as information coded in the line. However when I use the pluginmsg with all variables the button does not work when clicked.

The second question has to do with setting and reading the button checked value. I am setting to a "1" but reading that it is a "0".

I will post my test code. I am sure I am making a simple mistake, but I cannot spot the errors. Thanks for any help.

KeyStop.kmm
#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- KeyStop.kmm
#           T E S T I N G
# Dependencies        : main.kmm KMListBox
# Resources           : panorama image keystop.bmp in SKINS\DEFAULT 
# Preferences         : -
# Version             : 0.5  7/03/09 
# --------------------------------------------------------------------------------

KeyStop_RunCode{
alert("Button Action", "KeyStop", INFO);
#pluginmsg(toolbars, "CheckButton", "KeyStopBar,CloseOther",1);
pluginmsg(toolbars, "CheckButton", "KeyStopBar,CloseOther,1");
alert("checked set to interger 1","DEBUG",INFO);
$_KeyStop_bChecked = pluginmsgex(toolbars, "IsButtonChecked", "KeyStopBar,CloseOther", INT);
alert($_KeyStop_bChecked, "Value for $_KeyStop_bChecked DEBUG", INFO);
}

#From plugin documentation
# $bChecked = pluginmsgex(toolbars, "IsButtonChecked", "<ToolbarName>, <ButtonID>", INT);
# $bEnabled = pluginmsgex(toolbars, "IsButtonEnabled", "<ToolbarName>, <ButtonID>", INT);
# pluginmsg(toolbars, "CheckButton", "<ToolbarName>, <ButtonID>, [0|1]");
# pluginmsg(toolbars, "EnableButton", "<ToolbarName>, <ButtonID>, [0|1]");
# pluginmsg(toolbars, "SetButtonImage", "<ToolbarName>, <ButtonID>, [HOT|COLD|DEAD], Path/to/new/image.bmp[0]");
# pluginmsg(toolbars, "AddToolbar", "<ToolbarName>, <ButtonWidth>, <ButtonHeight>","");
# pluginmsg(toolbars, "AddButton", "<ToolbarName>, <ButtonName>, <Command>, <MenuName>, <TooltipText>, <ButtonWidth>, <ButtonHeight>, hot.bmp[0], cold.bmp[0], dead.bmp[0]","");

_KeyStop_BuildBar{
$_KS_ToolbarName = "KeyStopBar" ;
$_KS_BSize = "16" ;
$_KS_LastItem = "" ;
$_KS_AddBarTag = $_KS_ToolbarName .",". $_KS_BSize .",". $_KS_BSize .",". $_KS_LastItem ; 
pluginmsg(toolbars, "AddToolbar", $_KS_AddBarTag);

$_KS_ButtonName = "CloseOther" ;
#$_NB_Command = ID_CLOSE_ALLOTHERTAB ;
$_KS_Command = "macros(\".\"KeyStop_RunCode\".\")" ;
alert($_KS_Command, "$_KS_Command DEBUG", INFO);
$_KS_MenuName = "" ;
$_KS_tipText = "Disable/Enable local keys";
$_KS_ImageHot = "keystop.bmp[2]" ;
$_KS_ImageCold = "keystop.bmp[0]" ;
$_KS_ImageDead = "keystop.bmp[1]" ;
## Create third parameter for pluginmsg
#$_KS_AddButtonTag = $_KS_ToolbarName.",".$_KS_ButtonName.",".$_KS_Command.",".$_KS_MenuName.",".$_KS_tipText.",".$_KS_BSize.",".$_KS_BSize.",".$_KS_ImageHot.",".$_KS_ImageCold.",".$_KS_ImageDead.",".$_KS_LastItem ; 
$_KS_AddButtonTag = $_KS_ToolbarName.",".$_KS_ButtonName.",macros("."KeyStop_RunCode"."),".$_KS_MenuName.",".$_KS_tipText.",".$_KS_BSize.",".$_KS_BSize.",".$_KS_ImageHot.",".$_KS_ImageCold.",".$_KS_ImageDead.",".$_KS_LastItem ; 
pluginmsg(toolbars, "AddButton", $_KS_AddButtonTag);
}

$OnSetup=$OnSetup."_KeyStop_BuildBar;";
$macroModules=$macroModules."KeyStop;";


Options: ReplyQuote
Re: Questions on pluginmsg(toolbars ...
Posted by: desga2
Date: July 03, 2009 07:21PM

Try to change this line:
$_KS_Command = "macros(\".\"KeyStop_RunCode\".\")" ;
To this:
$_KS_Command = "macros(KeyStop_RunCode)" ;

Toolbars plugin is a little special with doubles quotes.
Really double quotes aren't used in toolbars.cfg file and this macro function work as add the toolbar and button code to toolbars.cfg file.

K-Meleon in Spanish



Edited 4 time(s). Last edit at 07/03/2009 07:28PM by desga2.

Options: ReplyQuote
Re: Questions on pluginmsg(toolbars ...
Posted by: JamesD
Date: July 03, 2009 07:37PM

@ desga2

Great! That worked just fine.

Do you have any ideas on my buttonchecked problem?

Options: ReplyQuote
Re: Questions on pluginmsg(toolbars ...
Posted by: desga2
Date: July 03, 2009 08:09PM

From Plugin commands for macros documentation:
Quote
PluginCommands
Note:

* Currently, buttons are identified by command, not by name. Consequently,
<ButtonID> must be replaced by the command associated to the button rather
than the button's name.

I think this is your problem. Change this lines in your code:
KeyStop_RunCode{
alert("Button Action", "KeyStop", INFO);
#pluginmsg(toolbars, "CheckButton", "KeyStopBar,CloseOther",1);
pluginmsg(toolbars, "CheckButton", "KeyStopBar,CloseOther,1");
alert("checked set to interger 1","DEBUG",INFO);
$_KeyStop_bChecked = pluginmsgex(toolbars, "IsButtonChecked", "KeyStopBar,CloseOther", INT);
alert($_KeyStop_bChecked, "Value for $_KeyStop_bChecked DEBUG", INFO);
}

Change the button name to the button command: CloseOther => macros(KeyStop_RunCode)

Like this:
KeyStop_RunCode{
alert("Button Action", "KeyStop", INFO);
#pluginmsg(toolbars, "CheckButton", "KeyStopBar,CloseOther",1);
pluginmsg(toolbars, "CheckButton", "KeyStopBar,macros(KeyStop_RunCode),1");
alert("checked set to interger 1","DEBUG",INFO);
$_KeyStop_bChecked = pluginmsgex(toolbars, "IsButtonChecked", "KeyStopBar,macros(KeyStop_RunCode)", INT);
alert($_KeyStop_bChecked, "Value for $_KeyStop_bChecked DEBUG", INFO);
}

K-Meleon in Spanish



Edited 4 time(s). Last edit at 07/03/2009 08:14PM by desga2.

Options: ReplyQuote
Re: Questions on pluginmsg(toolbars ...
Posted by: JamesD
Date: July 04, 2009 12:34AM

@ desga2

Thanks, I knew it would be a simple explanation. I am going to fill up my test code with comments to remind me of why things are the way they are.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.