Can I know which key is hit in the GuiTextEditCtrl?
by game4Rest · in Torque Game Builder · 03/21/2006 (1:06 am) · 3 replies
I made a GuiTextEditCtrl(chatMsg) and a send button(SndBttn) for the players to chat. When they want to send any messages to the other, it can be done by clicking sendButton. when they click send button it calls
a function called sendMsg() through the code something like this.
But I would like to make them just hit 'Enter' key instead of clicking button as that is more convenient for them. First I tried to add a "Accelerator = "Return";" to SndBttn. But as the 'Return' key is to be hit when the
focus is in chatMsg, I got no result.
When I put something in the GuiTextEditCtrl like this, it gave me messages everytime I hit any key.
So, how can I know when the 'Return' key is pressed when the focus is in the GuiTextEditCtrl?
Or is there better way to solve my problem?
Any advice will be highly appreciated.
Thank you in advance.
Hong Jin
a function called sendMsg() through the code something like this.
%msg = chatMsg.getValue();
commandToServer('processLine', %msg);But I would like to make them just hit 'Enter' key instead of clicking button as that is more convenient for them. First I tried to add a "Accelerator = "Return";" to SndBttn. But as the 'Return' key is to be hit when the
focus is in chatMsg, I got no result.
When I put something in the GuiTextEditCtrl like this, it gave me messages everytime I hit any key.
command = "sendMsg();"; //added in GuiTextEditCtrl
function sendMsg() //the sendMsg()
{
%msg = chatMsg.getValue();
messageBoxOk("","key pressed"@%msg, "");
}So, how can I know when the 'Return' key is pressed when the focus is in the GuiTextEditCtrl?
Or is there better way to solve my problem?
Any advice will be highly appreciated.
Thank you in advance.
Hong Jin
About the author
Recent Threads
#2
You always enlighten me. I made a success with your advice.
But I'm afraid I don't know the exact usage of altcommand(alternative command?) still.
Could you let me know the usage of it?
*edit*
I have encountered another problem regarding guitexteditcontrl. That is, when I try to
move my avatar(by pressing left or right key) before hitting the 'enter' key, I couldn't, because the focus is still in the texteditcontrl.
I've tried to find the answer to move my avatar when the focus is in the guitexteditcontrl for several
hours, but I couldn't.
Would someone give me any advice?
Thanks in advance.
Hong Jin
03/21/2006 (5:41 pm)
Luke, thank you very much.You always enlighten me. I made a success with your advice.
But I'm afraid I don't know the exact usage of altcommand(alternative command?) still.
Could you let me know the usage of it?
*edit*
I have encountered another problem regarding guitexteditcontrl. That is, when I try to
move my avatar(by pressing left or right key) before hitting the 'enter' key, I couldn't, because the focus is still in the texteditcontrl.
I've tried to find the answer to move my avatar when the focus is in the guitexteditcontrl for several
hours, but I couldn't.
Would someone give me any advice?
Thanks in advance.
Hong Jin
#3
above. It is only for the Return/enter key. I'm afraid I'm considering everything too seriously. So forget above
my question.
But still, I have no answer for the second question. So would anyone give me any hint?
I've tried 'Canvas.repaint()','setvisible()','CursorOff'... in vain. It seems like I'm the first one
who has problem like this.
Thanks.
Hong Jin
03/23/2006 (1:48 am)
Luke, I think I asked you too foolish question. AltCommand is nothing special but it is as you explainedabove. It is only for the Return/enter key. I'm afraid I'm considering everything too seriously. So forget above
my question.
But still, I have no answer for the second question. So would anyone give me any hint?
I've tried 'Canvas.repaint()','setvisible()','CursorOff'... in vain. It seems like I'm the first one
who has problem like this.
Thanks.
Hong Jin
Torque 3D Owner Luke D
Default Studio Name
And you should get the result you're looking for.