Shoutbox

Menu problem - 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: Menu problem (/showthread.php?tid=88608)

Menu problem by djdannyp on 01-21-2009 at 10:14 AM

code:
function OnGetScriptMenu(Location)
{
    var myMenu = "<ScriptMenu>";
    myMenu += "<MenuEntry Id=\"mnuNew\">New</MenuEntry>";
    myMenu += "<Separator/>";
    myMenu += "<MenuEntry Id=\"mnuAbout\">About...</MenuEntry>";
    myMenu += "</ScriptMenu>";
    return myMenu;
}
   
function OnEvent_MenuClicked(MenuItemId, Location, OriginWind)
{
    if (MenuItemId == "mnuNew") {
        WndNew = MsgPlus.CreateWnd("New.xml", "mnuNew");           
    } else if (MenuItemId == "mnuAbout") {
        WndAbout = MsgPlus.CreateWnd("About.xml", "mnuAbout");
}

that's some code I've got to make a menu (for a script that I'm probably going to need more help on once I get my head around exactly what i'm doing!)

However I can't now get the windows to show.

The menus are created properly, there's no errors in the debug window, the xml files load successfully in the tester (and I've tried substituting one for a menu window from another script which works)

I'm at a complete loss :S
RE: Menu problem by mynetx on 01-21-2009 at 10:28 AM

JScript code:
function OnEvent_MenuClicked(MenuItemId, Location, OriginWind)
{
    if (MenuItemId == "mnuNew") {
        WndNew = MsgPlus.CreateWnd("New.xml", "mnuNew");          
    } else if (MenuItemId == "mnuAbout") {
        WndAbout = MsgPlus.CreateWnd("About.xml", "mnuAbout");
}

The "else if" block has no closing curled bracket.
RE: Menu problem by Spunky on 01-21-2009 at 10:30 AM

Did you save the New.xml in Unicode?

EDIT: And what mynetx said, although you didn't mention a syntax error so I wasn't looking that deep into it :p


RE: Menu problem by djdannyp on 01-21-2009 at 11:08 AM

There's no syntax error, I just didn't copy it properly into here, lol

and yeah, New.xml is saved as Unicode, and as I said I tried another xml file in its place from a script who's menus do load...and still nothing

it's really bizarre


RE: Menu problem by Spunky on 01-21-2009 at 11:16 AM

Just try:

code:
function OnEvent_MenuClicked(MenuItemId, Location, OriginWind)
{
        WndNew = MsgPlus.CreateWnd("New.xml", "mnuNew");           
}


RE: Menu problem by mynetx on 01-21-2009 at 11:18 AM

Maybe you should pack us a copy of the script and attach it to let us debug it.


RE: Menu problem by djdannyp on 01-21-2009 at 12:16 PM

Here it is

The script itself probably doesn't work yet (infact it almost certainly doesn't work)

But it's not much use if I can't load the menus, lol

It's really bizarre.....i tried using Spunky's suggested code with literally nothing else in the code (except obviously the code to construct the menu)

the OnEvent_MenuClicked does get called properly (as shown in the debut window)....but just nothing shows

Edit: Attachment removed


RE: Menu problem by Matti on 01-21-2009 at 12:25 PM

The problem lies in the fact that you're trying to use some kind of menu identifier as window identifier.

In your JScript:

Javascript code:
WndNew = MsgPlus.CreateWnd("New.xml", "mnuNew");

In your interfaces XML:
XML code:
<Window Id="options" Version="1">

The "mnuNew" should be replaced by "options" so that Plus! can find the right window to load. Same goes for the about window: you defined it as "About" in your interfaces but you try to open "mnuAbout".
RE: Menu problem by djdannyp on 01-21-2009 at 02:26 PM

Woo, that got it sorted.....can't believe it was something so stupid!