Skip to content

Instantly share code, notes, and snippets.

@quentint
Created June 29, 2012 09:10
Show Gist options
  • Save quentint/3016844 to your computer and use it in GitHub Desktop.
Save quentint/3016844 to your computer and use it in GitHub Desktop.
KeyobardEvent issue with Starling
package net.tw.weatherApp.views.prompt {
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import org.josht.starling.foxhole.controls.Button;
import org.josht.starling.foxhole.controls.List;
import org.josht.starling.foxhole.controls.TextInput;
import org.josht.starling.foxhole.data.ListCollection;
import org.osflash.signals.Signal;
import starling.core.Starling;
import starling.display.Quad;
import starling.display.Sprite;
public class LocationFinder extends Sprite {
protected static const PADDING:uint=20;
protected var _searchInput:TextInput;
public const searchRequested:Signal=new Signal(String);
public const locationSelected:Signal=new Signal(Location);
public function init():void {
_searchInput=new TextInput();
_searchInput.x=_searchInput.y=PADDING;
_searchInput.width=stage.stageWidth-2*PADDING;
addChild(_searchInput);
Starling.current.nativeStage.addEventListener(KeyboardEvent.KEY_DOWN, onKey);
}
protected function onKey(e:KeyboardEvent):void {
trace(e.keyCode, e.charCode, e.keyLocation, Keyboard.ENTER);
if (e.keyCode==Keyboard.ENTER) {
trace('search');
onSearchGo();
}
}
protected function onSearchGo(target:Button=null):void {
searchRequested.dispatch(_searchInput.text);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment