General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Need help with rebuildmenu()
Posted by: JamesD
Date: September 16, 2007 10:55PM

I thought I knew how to use rebuildmenu(), but apparently my understanding of that statement is faulty. Every time I call _PgLdSound_ModMenu in my macro I get another copy of the "Page Load Sound" menu in the Tools menu. The menu is built at init and rebuilt every time I run the configure option. After two times using configure I have three copies of the menu. This code is very incomplete but the menu is partly working.

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- PgLdSound.kmm
# ---------- K-Meleon Macro Language Play Sound at Page Load ---------------
#
# Dependencies : main.kmm
# Resources : - sound files *.wav and Sounder.exe
# Preferences : -
# Version : 0.4 2007-09-16
# --------------------------------------------------------------------------------

_PgLdSound_Sound_Play{

$_PgLdSound_Use = getpref( BOOL , "k-meleon_pgldsound_use" );
$_PgLdSound_Choice = getpref( STRING , "k-meleon_pgldsound_choice" );
$_PgLdSound_Use ==true ? exec("\"".getfolder(UserMacroFolder)."\\PgLdSound\\sounder.exe\" ".$_PgLdSound_Choice."") : 0;
}

_PgLdSound_Sound_On{
# check mark the on menu;

# uncheck mark the off menu;

# set the userpref k-meleon_pgldsound_use to true;
setpref( BOOL , "k-meleon_pgldsound_use", true );
}

_PgLdSound_Sound_Off{
# check mark the off menu;

# uncheck mark the on menu;

# set the userpref k-meleon pgldsound_use to false;
setpref( BOOL , "k-meleon_pgldsound_use", false );
}

_PgLdSound_Configure{
#Prompts the user for a file, displaying only the files matching the pattern.
$_PgLdSound_Choice_Path = promptforfile( $_PgLdSound_Path, "Sound Files", "*.wav" );
$_PLS_Length = length($_PgLdSound_Path );
setpref( STRING, "k-meleon_pgldsound_choice", substr($_PgLdSound_Choice_Path, $_PLS_Length + 1 ));
&_PgLdSound_ModMenu ;
}

_PgLdSound_ModMenu{
$_PgLdSound_Popm = "Page Load Sound";
setmenu("&Tools",popup,$_PgLdSound_Popm,Misc);
setmenu($_PgLdSound_Popm,macro,"ON" . " (" .getpref( STRING , "k-meleon_pgldsound_choice" ) ." )",_PgLdSound_Sound_On,0);
setmenu($_PgLdSound_Popm,macro,"OFF",_PgLdSound_Sound_Off,1);
setmenu($_PgLdSound_Popm,separator,2);
setmenu($_PgLdSound_Popm,macro,"Configure ...",_PgLdSound_Configure,3);
rebuildmenu($_PgLdSound_Popm);
#setclipboard("ON" .getpref( STRING , "k-meleon_pgldsound_choice" ));
}

_PgLdSound_Get_Path{
### sounder.exe is supposed to be located in a subfolder, PgLdSound, of the user macro folder.
##$_PgLdSound_Data=readfile(getfolder(MacroFolder)."\\PgLdSound.kmm");
$_PgLdSound_Path=getfolder(UserMacroFolder)."\\PgLdSound";
##setclipboard( "path is " .$_PgLdSound_Path );
}

$OnStartup=$OnStartup."_PgLdSound_Get_Path;";
$OnInit=$OnInit."_PgLdSound_ModMenu;";
$OnLoad=$OnLoad."_PgLdSound_Sound_Play;";
$macroModules=$macroModules."PgLdSound;");

Options: ReplyQuote
Re: Need help with rebuildmenu()
Posted by: JamesD
Date: September 17, 2007 10:50PM

OK, I have got it now.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.