General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Creating new bar and button from a macro
Posted by: JamesD
Date: February 14, 2009 04:08AM

I seem to need some help getting these plugin messages to create a new bar and button. I think I have the input fields correct, but no bar or button is created. Where would a new bar show? Is a menu name required? Am I doing the last blank field correctly?

Any suggestions greatly appreciated.

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- NewButton.kmm
# ---------- code testing - NEW BAR AND NEW BUTTON
#
# Dependencies        : main.kmm
# Resources           : -  
# Preferences         : -
# Version             : - 0.1  2/13/09 
# --------------------------------------------------------------------------------

_NewButton_RunCode{

#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]","");

$_NB_ToolbarName = "MacroEmbed" ;
$_NB_BWidth = "16" ;
$_NB_BHeight = "16" ;
$_NB_LastItem = "" ;

$_NB_AddBarTag = $_NB_ToolbarName .",". $_NB_BWidth .",". $_NB_BHeight .",". $_NB_LastItem ; 

pluginmsg(toolbars, "AddToolbar", $_NB_AddBarTag);

$_NB_ButtonName = "CloseOther" ;
$_NB_Command = ID_CLOSE_ALLOTHERTAB ;
$_NB_MenuName = "" ;
$_NB_tipText = "Close Tabs Except Current";
$_NB_ImageHot = "Nuke_0.bmp" ;
$_NB_ImageCold = "Nuke_1.bmp" ;
$_NB_ImageDead = "Nuke_2.bmp" ;

$_NB_AddButtonTag = $_NB_ButtonName.",".$_NB_Command.",".$_NB_MenuName.",".$_NB_tipText.",".$_NB_ImageHot.",".$_NB_ImageCold.",".$_NB_ImageDead.",".$_NB_LastItem ; 

pluginmsg(toolbars, "AddButton", $_NB_AddButtonTag);
}

_NewButton_Display{
alert( $_NB_AddBarTag, "AddBarTag  DEBUG", INFO);
alert( $_NB_AddButtonTag, "AddButtonTag  DEBUG", INFO);
}

$OnSetup=$OnSetup."_NewButton_RunCode;";
$OnStartup=$OnStartup."_NewButton_Display;";
$macroModules=$macroModules."NewButton;";



Options: ReplyQuote
Re: Creating new bar and button from a macro
Posted by: desga2
Date: February 14, 2009 01:37PM

Documentation available.

#pluginmsg(toolbars, "AddToolbar", "<ToolbarName>, <ButtonWidth>, <ButtonHeight>","");
$_NB_AddBarTag = $_NB_ToolbarName .",". $_NB_BWidth .",". $_NB_BHeight .",". $_NB_LastItem ; 

pluginmsg(toolbars, "AddToolbar", $_NB_AddBarTag);
# I think this is OK.

#pluginmsg(toolbars, "AddButton", "<ToolbarName>, <ButtonName>, <Command>, <MenuName>, <TooltipText>, <ButtonWidth>, <ButtonHeight>, hot.bmp[0], cold.bmp[0], dead.bmp[0]","");
$_NB_AddButtonTag = $_NB_ToolbarName.",". $_NB_ButtonName.",".$_NB_Command.",".$_NB_MenuName.",".$_NB_tipText.",". $_NB_BWidth .",". $_NB_BHeight .",".$_NB_ImageHot.",".$_NB_ImageCold.",".$_NB_ImageDead.",".$_NB_LastItem ; 
# Your problem is here, you need add ToolbarName and button Height and Width sizes.
pluginmsg(toolbars, "AddButton", $_NB_AddButtonTag);

If not work try to put "toolbars" between double quotes.

K-Meleon in Spanish



Edited 2 time(s). Last edit at 02/14/2009 01:39PM by desga2.

Options: ReplyQuote
Re: Creating new bar and button from a macro
Posted by: JamesD
Date: February 14, 2009 02:17PM

@ desga2

I can't believe I missed those items. Thanks. Everything is working except there is no image on the button. I have double checked and the bmp files exist in SKINS\DEFAULT. The button exists on its own toolbar which displayed just under the throbber. The function works and closes all tabs except the current tab.

Can anyone see what I have missed doing for the images to appear on the button?

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- NewButton.kmm
# ---------- code testing - NEW BAR AND NEW BUTTON
#
# Dependencies        : main.kmm
# Resources           : -  
# Preferences         : -
# Version             : - 0.2  2/14/09 
# --------------------------------------------------------------------------------

_NewButton_RunCode{

#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]","");

$_NB_ToolbarName = "MacroEmbed" ;
$_NB_BWidth = "16" ;
$_NB_BHeight = "16" ;
$_NB_LastItem = "" ;

$_NB_AddBarTag = $_NB_ToolbarName .",". $_NB_BWidth .",". $_NB_BHeight .",". $_NB_LastItem ; 

pluginmsg(toolbars, "AddToolbar", $_NB_AddBarTag);

$_NB_ButtonName = "CloseOther" ;
$_NB_Command = ID_CLOSE_ALLOTHERTAB ;
$_NB_MenuName = "" ;
$_NB_tipText = "Close Tabs Except Current";
$_NB_ImageHot = "Nuke_0.bmp" ;
$_NB_ImageCold = "Nuke_1.bmp" ;
$_NB_ImageDead = "Nuke_2.bmp" ;

$_NB_AddButtonTag = $_NB_ToolbarName.",".$_NB_ButtonName.",".$_NB_Command.",".$_NB_MenuName.",".$_NB_tipText.",".$_NB_BWidth.",".$_NB_BHeight.",".$_NB_ImageHot.",".$_NB_ImageCold.",".$_NB_ImageDead.",".$_NB_LastItem ; 

pluginmsg(toolbars, "AddButton", $_NB_AddButtonTag);
}

_NewButton_Display{
alert( $_NB_AddBarTag, "AddBarTag  DEBUG", INFO);
alert( $_NB_AddButtonTag, "AddButtonTag  DEBUG", INFO);
}

$OnSetup=$OnSetup."_NewButton_RunCode;";
$OnStartup=$OnStartup."_NewButton_Display;";
$macroModules=$macroModules."NewButton;";



Options: ReplyQuote
Re: Creating new bar and button from a macro
Posted by: desga2
Date: February 14, 2009 03:42PM

Sorry I didn't look this before;


#pluginmsg(toolbars, "AddButton", "<ToolbarName>, <ButtonName>, <Command>, <MenuName>, <TooltipText>, <ButtonWidth>, <ButtonHeight>, hot.bmp[0], cold.bmp[0], dead.bmp[0]","");

# If you have 3 differents files for button state:
$_NB_ImageHot = "Nuke_0.bmp[0]" ;
$_NB_ImageCold = "Nuke_1.bmp[0]" ;
$_NB_ImageDead = "Nuke_2.bmp[0]" ;

# You need ever specific the index of image in file, in your case you are using 3 
# different files with an image in each (first image is zero index).
# If you use one file with 3 images; first is image.bmp[0], second is image.bmp[1]
# and third is image.bmp[2].

# Remember you can generate this panorama image with IrfanView:
# "Nuke.bmp[0]","Nuke.bmp[1]","Nuke.bmp[2]"

Usually icons are square,
$_NB_BWidth = "16" = $_NB_BHeight = "16"
You can use an unique variable for this, for example;
$_NB_BSize = "16"
and when you used it in function call this variable two times;
[...]$_NB_BSize .",". $_NB_BSize[...]
instead of
[...]$_NB_BWidth .",", $_NB_BHeight[...]

By this way you save some memory to use less variables.

K-Meleon in Spanish



Edited 3 time(s). Last edit at 02/14/2009 03:51PM by desga2.

Options: ReplyQuote
Re: Creating new bar and button from a macro
Posted by: JamesD
Date: February 14, 2009 08:08PM

@ desga2

I have made the panorama. I tried with just image name plus [x] and had no button. I then added path to image, but still no button on the bar.

The tooltips appear. The button area changes shading when I mouseover, and the non-appearing button works correctly when I click on it. There is just no button on the bar.

GOT IT NOW!!

I had my brackets in wrong place. Changed to Nuke.bmp[x]. Now it works. Thanks so much for the help.

$_NewButton_Path=getfolder(RootFolder)."\\Skins\\Default\\";
.
.
$_NB_ImageHot = $_NewButton_Path."Nuke[0].bmp" ;
$_NB_ImageCold = $_NewButton_Path."Nuke[1].bmp" ;
$_NB_ImageDead = $_NewButton_Path."Nuke[2].bmp" ;



Edited 1 time(s). Last edit at 02/14/2009 08:13PM by JamesD.

Options: ReplyQuote
Re: Creating new bar and button from a macro
Posted by: desga2
Date: February 14, 2009 09:52PM

Yes, you had the index in brackets in wrong place. It must be after file name.

$_NewButton_Path=getfolder(RootFolder)."\\Skins\\Default\\";
.
.
$_NB_ImageHot = $_NewButton_Path."Nuke.bmp[0]" ;
$_NB_ImageCold = $_NewButton_Path."Nuke.bmp[1]" ;
$_NB_ImageDead = $_NewButton_Path."Nuke.bmp[2]" ;

Another note, if you put your button icon files in "default" subfolder under skins folder, you don't need specific the path of file because K-Meleon search the file in this default folder by default.

K-Meleon in Spanish

Options: ReplyQuote
Re: Creating new bar and button from a macro
Posted by: JamesD
Date: February 15, 2009 01:33PM

@ desga2

Thanks for your help. I have it working now and that means I have a good model for a new bar or button if a future project requires them.

The image for the button is here. http://www.yourfilelink.com/get.php?fid=486330

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- NewButton.kmm
# ---------- code testing - NEW BAR AND NEW BUTTON FROM MACRO
#
# Dependencies        : main.kmm
# Resources           : panorama image nuke.bmp in SKINS\DEFAULT 
# Preferences         : -
# Version             : 0.4  2/15/09 
# --------------------------------------------------------------------------------

#From plugin documentation
#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]","");

_NewButton_RunCode{
$_NB_ToolbarName = "MacroEmbed" ;
$_NB_BSize = "16" ;
$_NB_LastItem = "" ;
$_NB_AddBarTag = $_NB_ToolbarName .",". $_NB_BSize .",". $_NB_BSize .",". $_NB_LastItem ; 
pluginmsg(toolbars, "AddToolbar", $_NB_AddBarTag);

$_NB_ButtonName = "CloseOther" ;
$_NB_Command = ID_CLOSE_ALLOTHERTAB ;
$_NB_MenuName = "" ;
$_NB_tipText = "Close Tabs Except Current";
$_NB_ImageHot = "Nuke.bmp[0]" ;
$_NB_ImageCold = "Nuke.bmp[1]" ;
$_NB_ImageDead = "Nuke.bmp[2]" ;
$_NB_AddButtonTag = $_NB_ToolbarName.",".$_NB_ButtonName.",".$_NB_Command.",".$_NB_MenuName.",".$_NB_tipText.",".$_NB_BSize.",".$_NB_BSize.",".$_NB_ImageHot.",".$_NB_ImageCold.",".$_NB_ImageDead.",".$_NB_LastItem ; 
pluginmsg(toolbars, "AddButton", $_NB_AddButtonTag);
}

$OnSetup=$OnSetup."_NewButton_RunCode;";
$macroModules=$macroModules."NewButton;";


Options: ReplyQuote


K-Meleon forum is powered by Phorum.