Created
June 29, 2012 09:10
-
-
Save quentint/3016844 to your computer and use it in GitHub Desktop.
KeyobardEvent issue with Starling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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