What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Replace EditText

Replace EditText
Author: Message:
mickael9
Full Member
***


Posts: 117
Reputation: 3
33 / Male / Flag
Joined: Jul 2005
RE: Replace EditText
quote:
Originally posted by ChristianAMD3000
Hi @ all friends

i got a big problem

i want replace the words in EditText-box during i write something.
e.g if i write "hallo"--> it must be changed in "Hello".

i used OnEvent_ChatWndSendMessage(); command and its working
but that is not realy usefull becouse i cant change the words if i make a mistake..

i think u all get it what my problem is.
it would be verry greatfull if somebody can help me :|

(Sorry My english *-))
Christian

Hi,
code:
var Params = {};
var ParamCount = 0;

var Replacements = {
"hallo" : "hello"
};

function OnEvent_ChatWndEditKeyDown(oChatWnd, nKeyCode, bCtrl, bShift)
{
    var sTimerId = "InlineRepl_" + (++ParamCount);
    Params[sTimerId] = oChatWnd;
    MsgPlus.AddTimer(sTimerId,100);
}

function OnEvent_Timer(sTimerId)
{
    if (sTimerId.substr(0, 11) == "InlineRepl_")
    {
        var Wnd        = Params[sTimerId];
        var nSelStart  = Wnd.EditText_GetCurSelStart();
        var nSelEnd    = Wnd.EditText_GetCurSelEnd();
        var nOldLength = Wnd.EditText.length;
        var sText      = Wnd.EditText;
       
        for (sKey in Replacements)
        {
            sText = sText.replace(sKey,Replacements[sKey]);
        }
        if (sText.length < nOldLength)
        {
            nSelStart -= (nOldLength - sText.length);
            nSelEnd   -= (nOldLength - sText.length);
        }
        else if (sText.length > nOldLength)
        {
            nSelStart += (sText.length - nOldLength);
            nSelEnd   += (sText.length - nOldLength);
        }
        Wnd.EditText = sText;
        Wnd.EditText_SetCurSel(nSelStart, nSelEnd);
       
        ParamCount--;
        delete(Params[sTimerId]);
    }
}
08-28-2006 03:31 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Replace EditText - by ChristianAMD3000 on 08-27-2006 at 10:38 PM
RE: Replace EditText - by mickael9 on 08-28-2006 at 03:31 AM
RE: Replace EditText - by RaceProUK on 08-28-2006 at 03:11 PM
RE: Replace EditText - by ChristianAMD3000 on 08-28-2006 at 05:10 PM
RE: Replace EditText - by RaceProUK on 08-28-2006 at 09:47 PM


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