ChatWnd.EditText is the text currently being typed by the user. Because you're using the OnEvent_ChatWndSendMessage, this will be empty as the message is already about to be sent and therefore the input area has been cleared. To change the message to be sent, you need to return the modified message at the end of your function.
Also, your replacing won't work either. First, you replace "hi" with "sfe" and store it in EditText. Then, you replace "hey" with "wagwan" in the original message and overwrite EditText, resulting in the first replacing being lost! In the end, you'll end up with only "helo" being replaced by "oi". A very simple solution is by saving the replacement result in the same variable as the one used for the replacing, which is "Message".
So, a fix for your code could be the following:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
var Greet1 = new Array();
Greet1[0] = "hi";
Greet1[1] = "hey";
Greet1[2] = "hello";
Greet1[3] = "helo";
var Greet2 = new Array();
Greet2[0] = "sfe";
Greet2[1] = "wagwan";
Greet2[2] = "yo"
Greet2[3] = "oi"
// No need to declare variable x twice
for (var x=0; x<4; x++)
{
Message = Message.replace(Greet1[x], Greet2[x]);
}
return Message;
}
Have a look at the changes and the explanation and make sure you understand what went wrong, so you can learn from it and won't make the same mistake again.