text input & enter/return
I was wondering how i could code this so when i hit the enter key in the text input field it does the same as clicking the send button.
I have googled this for hours and i cant seem to find something that works.
This is for a TelnetSocket using AS3
You can download the files i have Here (adobe live docs site) **look for the TelnetSocket file
Code:
package
{
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import com.example.programmingas3.socket.Telnet;
public class TelnetSocket extends Sprite
{
private var telnetClient:Telnet;
public function TelnetSocket() {
setupUI();
}
private function connect(e:MouseEvent):void {
telnetClient = new Telnet(serverName.text, int(portNumber.text), output);
}
private function sendCommand(e:MouseEvent):void {
var ba:ByteArray = new ByteArray();
ba.writeMultiByte(command.text + "\n", "UTF-8");
telnetClient.writeBytesToSocket(ba);
command.text = "";
}
private function setupUI():void {
loginBtn.addEventListener(MouseEvent.CLICK,connect)
sendBtn.addEventListener(MouseEvent.CLICK,sendCommand); //<-- Here is the "Send" button
}
}
}
I would appreciate any help thanks guys.