Replace EditText - 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: Replace EditText (/showthread.php?tid=65488)
Replace EditText by ChristianAMD3000 on 08-27-2006 at 10:38 PM
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
RE: Replace EditText by mickael9 on 08-28-2006 at 03:31 AM
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]);
}
}
RE: Replace EditText by RaceProUK on 08-28-2006 at 03:11 PM
Have you tested what happens if ParamCount wraps round?
RE: Replace EditText by ChristianAMD3000 on 08-28-2006 at 05:10 PM
uh!! its working fine.. but too much big
and i cant replace Characters
eg. if m -> Ma
ma -> something else..
but i solve it with a simple logik
var meinText ='';
var VK_0 ='';
OnEvent_ChatWndEditKeyDown(ChatWnd,KeyCode)
{
VK_0 = 32;
meinText = ChatWnd.EditText;
If (KeyCode == VK_0) // if i press space the word will be replaced
{
meinText = meinText.Replace...............ect;
ChatWnd.EditText = Text;
}
}
it was 3'O Clock when i finished
thx a lot 4 all
gruß
Christian
PS: once more ques.. I'm Delphi user can i use Delphi Codes here???
RE: Replace EditText by RaceProUK on 08-28-2006 at 09:47 PM
You can use bbCode to format a post. Use [code]<code>[/code] for code snippets.
|