flex結合キー
1906 ワード
ショートカットキーを使うと必ずキーがありますので、KeyboardEvent.KEY_を使います。UPで判断する
事件を使う時は、容器内に焦点を当てる。
事件を使う時は、容器内に焦点を当てる。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="creationCompleteHandler(event)">
<s:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle" gap="0"/>
</s:layout>
<fx:Declarations>
<!-- ( 、 ) -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
private function creationCompleteHandler(event:FlexEvent):void
{
bc.addEventListener( KeyboardEvent.KEY_UP, keyBoardHandler );
}
private function keyBoardHandler(event:KeyboardEvent):void{
var code:int = event.keyCode;
var ctrl:Boolean=event.ctrlKey;
if(ctrl)
{
Alert.show("ctrl+"+code)
}else{
Alert.show(code.toString())
}
text.text = ctrl+","+code;
trace(ctrl+","+code);
}
]]>
</fx:Script>
<s:BorderContainer id="bc" width="500" height="500" backgroundColor="0xff0000" borderStyle="solid" borderWeight="5" borderColor="0x000000">
<s:TextInput width="300" height="100"/>
</s:BorderContainer>
<s:TextInput id="text" width="100" height="25"/>
</s:Application>