What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Help with a menu selection

Help with a menu selection
Author: Message:
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. Help with a menu selection
Hey, again.

For my Programming Languages Keyword Script (C/C++ Keywords is gone, it has now support for over 12 languages), I am working on the menus. So far so good, but I can't get it able to click something, and to add something to his/her send message bar.

On the click of item "PHP", I want it to add (but not send):

[ code=php] [/code ]

I tried this:

code:
var talkerList = new Array(
"PHP", "C/C++");

function OnGetScriptMenu(Location){
    var sMenu = "<ScriptMenu>";
    if(Location == 1)
    {
            sMenu += "<MenuEntry Id=\"Help\">Help - How to Use</MenuEntry>";
            sMenu += "<MenuEntry Id=\"About\">About</MenuEntry>";
    }
    else if(Location == 2)
    {
        for(var i = 0; i < talkerList.length; i++)
            sMenu += "<MenuEntry Id=\""+talkerList[i]+""+talkerList[i]+"\">"+talkerList[i]+"</MenuEntry>";
        sMenu += "<Separator/>";
        sMenu += "<MenuEntry Id=\"Help\">Help - How to Use</MenuEntry>";
        sMenu += "<MenuEntry Id=\"About\">About</MenuEntry>";
    }
    sMenu += "</ScriptMenu>";
    return sMenu;
}

function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd)
{
    var currenttext = OriginWnd.EditText;
    switch(MenuItemId)
    {
            case "PHP":
                OriginWnd.EditText_SetCurSel (currenttext.substr(0,1), currenttext.substr(currenttext.length,1));
                OriginWnd.EditText_ReplaceSel ("[ code=php] [/code ]");
                break;
    }
}


It's about the PHP one. How will I get it to work?

- Jon

This post was edited on 07-09-2006 at 12:58 PM by Paril.
07-09-2006 12:57 PM
Profile E-Mail PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: Help with a menu selection
code:
sMenu += "<MenuEntry Id=\""+talkerList[i]+""+talkerList[i]+"\">"+talkerList[i]+"</MenuEntry>";

shouldn't that be:
code:
sMenu += "<MenuEntry Id=\""+talkerList[i]+"\">"+talkerList[i]+"</MenuEntry>";
07-09-2006 01:27 PM
Profile E-Mail PM Find Quote Report
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. RE: Help with a menu selection
I'll try that..

EDIT:
That's not what I'm having problems with, both work correctly.

I want it to add:

[ code=PHP] [ /code]

in the send message box, when you click on it.

This post was edited on 07-09-2006 at 01:30 PM by Paril.
07-09-2006 01:29 PM
Profile E-Mail PM Web Find Quote Report
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. RE: Help with a menu selection
It's this part here

function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd)
{
var currenttext = OriginWnd.EditText;
switch(MenuItemId)
{
         case "PHP":
         OriginWnd.EditText_SetCurSel (currenttext.substr(0,1), currenttext.substr(currenttext.length,1));
         OriginWnd.EditText_ReplaceSel ("[ code=php] [/code ]");
         break;
    }
}


it seems to not want to do anything..
07-09-2006 01:48 PM
Profile E-Mail PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: Help with a menu selection
You're using EditText_SetCurSel in the wrong way. The function takes 2 numbers, and you are passing 2 strings. You should do:

code:
function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd)
{
var currenttext = OriginWnd.EditText;
switch(MenuItemId)
{
         case "PHP":
         OriginWnd.EditText_SetCurSel (0, currenttext.length - 1);
         OriginWnd.EditText_ReplaceSel ("[ code=php] [/code ]");
         break;
    }
}

That will replace all text in the edit box with [ code=php][/code ]. To replace it with: [ code=php]oldtext[/code ] use:

code:
function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd)
{
var currenttext = OriginWnd.EditText;
switch(MenuItemId)
{
         case "PHP":
         OriginWnd.EditText_SetCurSel (0, currenttext.length - 1);
         OriginWnd.EditText_ReplaceSel ("[ code=php]"+currenttext+"[/code ]");
         break;
    }
}
07-09-2006 01:59 PM
Profile E-Mail PM Find Quote Report
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. RE: Help with a menu selection
Ah, thanks, will try it..

EDIT:
Thanks, it works!
:)

Expect a release soon.

This post was edited on 07-09-2006 at 02:03 PM by Paril.
07-09-2006 02:01 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On