Shoutbox

[Help!] Menu Troubles - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Help!] Menu Troubles (/showthread.php?tid=63405)

[Help!] Menu Troubles by fergofrog on 07-17-2006 at 01:33 AM

I am having some menu troubles with my script, here is my code (only for the menu):

code:
function OnGetScriptMenu (Location)
{
    var ScriptMenu = "<ScriptMenu>";
    ScriptMenu    +=     "<MenuEntry Id=\"MnuAbout\">About...</MenuEntry>";
    ScriptMenu    += "</ScriptMenu>";
   
    return ScriptMenu;
}

function OnEvent_MenuClicked ("MnuAbout", Location, OriginWnd)
{
    MsgPlus.CreateWnd('Window.xml', 'About');
}


When activating the script it says i have an error if i remove the:

code:
function OnEvent_MenuClicked ("MnuAbout", Location, OriginWnd)
{
    MsgPlus.CreateWnd('Window.xml', 'About');
}


It works again and if i just rename the "MnuAbout" to MenuItemId it works again. I just want the about button to work.
RE: [Help!] Menu Troubles by Silentdragon on 07-17-2006 at 01:35 AM

code:
function OnEvent_MenuClicked (MnuId, Location, OriginWnd)
{
if(MnuId == "MnuAbout")
       MsgPlus.CreateWnd('Window.xml', 'About');
}

You can't have quotes where a variable should be, but the above should make sense.
RE: [Help!] Menu Troubles by deAd on 07-17-2006 at 01:36 AM

EDIT: Beat me to it :P

code:
function OnEvent_MenuClicked (MenuItemId, Location, OriginWnd)
{
if(MenuItemId == "MnuAbout"){
MsgPlus.CreateWnd('Window.xml', 'About');
}
}

RE: [Help!] Menu Troubles by fergofrog on 07-17-2006 at 01:41 AM

Neither of those 2 worked. I got the same error. Here is my code now (just the menu):

code:
function OnGetScriptMenu (Location)
{
    var ScriptMenu = "<ScriptMenu>";
    ScriptMenu    +=     "<MenuEntry Id=\"MnuAbout\">About...</MenuEntry>";
    ScriptMenu    += "</ScriptMenu>";
   
    return ScriptMenu;
}

function OnEvent_MenuClicked (MenuItemId, Location, OriginWnd)
{
if(MenuItemId == "MnuAbout"){
    MsgPlus.CreateWnd('Window.xml', 'About');
}
}


RE: RE: [Help!] Menu Troubles by fergofrog on 07-17-2006 at 01:52 AM

quote:
Originally posted by BstrdSmkr
quote:
Originally posted by fergofrog
Neither of those 2 worked. I got the same error. Here is my code now (just the menu):

code:
function OnGetScriptMenu (Location)
{
    var ScriptMenu = "<ScriptMenu>";
    ScriptMenu    +=     "<MenuEntry Id=\"MnuAbout\">About...</MenuEntry>";
    ScriptMenu    += "</ScriptMenu>";
   
    return ScriptMenu;
}

function OnEvent_MenuClicked (MenuItemId, Location, OriginWnd)
{
if(MenuItemId == "MnuAbout"){
    MsgPlus.CreateWnd('Window.xml', 'About');
}
}



change the second set of double quotes to single quotes on line 3:

code:
ScriptMenu    +=     "<MenuEntry Id=\"MnuAbout\">About...</MenuEntry>";


should be:

code:
ScriptMenu    +=     "<MenuEntry Id=\'MnuAbout\'>About...</MenuEntry>";


see if that works


No that didn't work, the problem is in the OnEvent_MenuClicked i think.
RE: [Help!] Menu Troubles by Silentdragon on 07-17-2006 at 01:53 AM

I don't think that'll work. It shouldn't matter, and I'm not sure if ' is valid for xml.

This code should work, I can't exactly test it as I dont' have plus at the moment but I'm 99% sure its valid.

code:
function OnGetScriptMenu(Location)
{
        var ScriptMenu = "<ScriptMenu>";
        ScriptMenu    +=     "<MenuEntry Id=\"MnuAbout\">About...</MenuEntry>";
        ScriptMenu    += "</ScriptMenu>";

       return ScriptMenu;
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
        if(MenuItemId == "MnuAbout")
                 MsgPlus.CreateWnd('Window.xml', 'About');
}

RE: [Help!] Menu Troubles by fergofrog on 07-17-2006 at 02:10 AM

The script is working, only when i click on About... it doesn't open any thing. Here is my script so far (only them menu part):

code:
function OnGetScriptMenu(Location)
{
        var ScriptMenu = "<ScriptMenu>";
        ScriptMenu     +=         "<MenuEntry Id=\"MnuAbout\">About...</MenuEntry>";
        ScriptMenu     += "</ScriptMenu>";

    return ScriptMenu;
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
    if(MenuItemId == "MnuAbout")
        MsgPlus.CreateWnd('Window.xml', 'About');
}


RE: [Help!] Menu Troubles by Silentdragon on 07-17-2006 at 02:12 AM

Is the xml saved as Unicode? Open in wordpad then save as unicode. If it still doesn't work then its a problem with your xml.


RE: [Help!] Menu Troubles by fergofrog on 07-17-2006 at 03:07 AM

Thanks heaps that unicode thing worked! How do i get my Close button to work i have in Window.xml:

code:
            <Control xsi:type="ButtonControl" Id="BtnClose">
                <Position Left="112" Top="25" Width="50"/>
                <Caption>Close</Caption>
            </Control>


And in my script i have:
code:
function OnWndTestEvent_CtrlClicked(Wnd, ControlId)
{
        if(ControlId == "BtnClose")
                Wnd.Close(1);
}


RE: [Help!] Menu Troubles by Silentdragon on 07-17-2006 at 03:09 AM

code:
function OnAboutEvent_CtrlClicked(Wnd, ControlId)
{
if(ControlId == "BtnClose")
Wnd.Close(1);
}

Thats assuming the window in the xml file is called About
RE: [Help!] Menu Troubles by fergofrog on 07-17-2006 at 03:11 AM

Thnks that worked, i now see where i went wrong, thanks all for all your help!


RE: [Help!] Menu Troubles by cooldude_i06 on 07-17-2006 at 04:28 AM

quote:
Originally posted by fergofrog
Thanks heaps that unicode thing worked! How do i get my Close button to work i have in Window.xml:
code:
            <Control xsi:type="ButtonControl" Id="BtnClose">
                <Position Left="112" Top="25" Width="50"/>
                <Caption>Close</Caption>
            </Control>


And in my script i have:
code:
function OnWndTestEvent_CtrlClicked(Wnd, ControlId)
{
        if(ControlId == "BtnClose")
                Wnd.Close(1);
}



Btw, if you want to have a Close button, you don't need any code at all. Just name the button "BtnCancel".