<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:controls="com.schelterstudios.hotKeySystem.mx.controls.*"
xmlns:containers="com.schelterstudios.hotKeySystem.mx.containers.*"
xmlns:managers="com.schelterstudios.hotKeySystem.mx.managers.*"
layout="absolute" horizontalAlign="center" verticalAlign="middle"
initialize="init()" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import com.schelterstudios.hotKeySystem.flash.ui.HotKeyCodes;
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
import mx.managers.PopUpManagerChildList;
private var windowPopped:Boolean = false;
private function init():void{
window.addEventListener(CloseEvent.CLOSE, windowCloseHandler);
}
private function displayTitleWindow():void{
if(windowPopped) return;
PopUpManager.addPopUp(window, Sprite(Application.application), false, PopUpManagerChildList.POPUP);
window.setHotKeyFocus();
window.visible = true;
windowPopped = true;
}
private function windowCloseHandler(evt:CloseEvent):void{
if(!windowPopped) return;
PopUpManager.removePopUp(window);
popupGroup.enabled = false;
windowPopped = false;
}
]]>
</mx:Script>
<mx:Style source="default.css"/>
<managers:HotKeyGroup id="defaultGroup"/>
<managers:HotKeyGroup id="group2Group" name="group2"/>
<managers:HotKeyGroup id="popupGroup" name="popup"/>
<containers:KeyableTitleWindow id="window" showCloseButton="true" hotKeyGroupName="popup"
visible="false" horizontalCenter="-160" verticalCenter="150" title="popup hotkey buttons" x="0" y="264">
<mx:VBox verticalGap="2">
<mx:HBox horizontalGap="2">
<controls:KeyableButton label="A" hotKey="{HotKeyCodes.A}" hotKeyGroupName="popup" toolTip="Standard Button (A)" width="80"/>
<controls:KeyableButton label="B" hotKey="{HotKeyCodes.B}" hotKeyGroupName="popup" toolTip="Toggle Button (B)" toggle="true" width="80"/>
<controls:KeyableButton label="C" hotKey="{HotKeyCodes.C}" hotKeyGroupName="popup" toolTip="Disabled Button (C)" width="80" enabled="true"/>
</mx:HBox>
<mx:HBox horizontalGap="2">
<controls:KeyableButton label="CTRL A" hotKey="{HotKeyCodes.CTRL_A}" hotKeyGroupName="popup" toolTip="Standard Button (Ctrl + A)" width="80"/>
<controls:KeyableButton label="CTRL B" hotKey="{HotKeyCodes.CTRL_B}" hotKeyGroupName="popup" toolTip="Toggle Button (Ctrl + B)" width="80" toggle="true"/>
<controls:KeyableButton label="CTRL C" hotKey="{HotKeyCodes.CTRL_C}" hotKeyGroupName="popup" toolTip="Disabled Button (Ctrl + C)" width="80"/>
</mx:HBox>
<mx:Spacer height="10"/>
<mx:TextArea width="100%" height="50">
<mx:text>The close button on a KeyableTitleWindow can also be triggered via ESC if its hotkey group is receiving hotkey events.</mx:text>
</mx:TextArea>
</mx:VBox>
</containers:KeyableTitleWindow>
<mx:Panel horizontalCenter="0" verticalCenter="0.5" layout="absolute" height="519" width="636" title="Hot Key Demonstration" styleName="mainPanel">
<mx:VBox horizontalCenter="-160" verticalCenter="-100" verticalGap="2" x="0" y="0">
<mx:Label text="default hotkey buttons" fontWeight="bold"/>
<mx:HBox horizontalGap="2">
<controls:KeyableButton label="A" hotKey="{HotKeyCodes.A}" toolTip="Standard Button (A)" width="80"/>
<controls:KeyableButton label="B" hotKey="{HotKeyCodes.B}" toolTip="Toggle Button (B)" toggle="true" width="80"/>
<controls:KeyableButton label="C" hotKey="{HotKeyCodes.C}" toolTip="Standard Button (C)" width="80"/>
</mx:HBox>
<mx:HBox horizontalGap="2">
<controls:KeyableButton label="CTRL A" hotKey="{HotKeyCodes.CTRL_A}" toolTip="Standard Button (Ctrl + A)" width="80"/>
<controls:KeyableButton label="CTRL B" hotKey="{HotKeyCodes.CTRL_B}" toolTip="Toggle Button (Ctrl + B)" width="80" toggle="true"/>
<controls:KeyableButton label="CTRL C" hotKey="{HotKeyCodes.CTRL_C}" toolTip="Standard Button (Ctrl + C)" width="80"/>
</mx:HBox>
<controls:KeyableButton label="Display TitleWindow (Ctrl + D)" hotKey="{HotKeyCodes.CTRL_D}" toolTip="Display TitleWindow (Ctrl + D)" width="100%"
click="displayTitleWindow()"/>
<mx:Spacer height="10"/>
<mx:Label text="group2 hotkey buttons" fontWeight="bold"/>
<mx:HBox horizontalGap="2">
<controls:KeyableButton label="A" hotKey="{HotKeyCodes.A}" hotKeyGroupName="group2" toolTip="Standard Button (A)" width="80"/>
<controls:KeyableButton label="B" hotKey="{HotKeyCodes.B}" hotKeyGroupName="group2" toolTip="Toggle Button (B)" toggle="true" width="80"/>
<controls:KeyableButton label="C" hotKey="{HotKeyCodes.C}" hotKeyGroupName="group2" toolTip="Standard Button (C)" width="80"/>
</mx:HBox>
<mx:HBox horizontalGap="2">
<controls:KeyableButton label="CTRL A" hotKey="{HotKeyCodes.CTRL_A}" hotKeyGroupName="group2" toolTip="Standard Button (Ctrl + A)" width="80"/>
<controls:KeyableButton label="CTRL B" hotKey="{HotKeyCodes.CTRL_B}" hotKeyGroupName="group2" toolTip="Toggle Button (Ctrl + B)" width="80" toggle="true"/>
<controls:KeyableButton label="CTRL C" hotKey="{HotKeyCodes.CTRL_C}" hotKeyGroupName="group2" toolTip="Standard Button (Ctrl + C)" width="80"/>
</mx:HBox>
<controls:KeyableButton label="Display TitleWindow (Ctrl + D)" hotKey="{HotKeyCodes.CTRL_D}" hotKeyGroupName="group2" toolTip="Display TitleWindow (Ctrl + D)" width="100%"
click="displayTitleWindow()"/>
<mx:Spacer height="10"/>
<mx:TextArea width="100%" height="50">
<mx:text>Focused TextFields automatically block hotkey triggers.</mx:text>
</mx:TextArea>
</mx:VBox>
<mx:VBox height="100%" verticalCenter="0" horizontalScrollPolicy="off" verticalScrollPolicy="off" right="0" width="50%" verticalAlign="middle" backgroundColor="#f2f2f2" paddingLeft="30" borderStyle="solid" borderThickness="1" borderColor="#000000">
<mx:Form width="100%">
<mx:FormHeading label="default hotkey group" indicatorGap="4"/>
<mx:FormItem label="priority" indicatorGap="4" width="100%">
<mx:HBox horizontalGap="1" verticalAlign="middle">
<mx:Button label="-" click="{defaultGroup.priority--}" width="20"/>
<mx:TextInput text="{defaultGroup.priority}" editable="false" width="30"/>
<mx:Button label="+" click="{defaultGroup.priority++}" width="20"/>
<mx:Spacer width="10"/>
<mx:CheckBox id="cb0" selected="{defaultGroup.enabled}" change="{defaultGroup.enabled=cb0.selected}" label="enabled"/>
</mx:HBox>
</mx:FormItem>
<mx:FormItem width="100%" indicatorGap="4">
<mx:Button label="setHotKeyFocus" click="{defaultGroup.setHotKeyFocus()}"/>
</mx:FormItem>
</mx:Form>
<mx:Form width="100%">
<mx:FormHeading label="group2 hotkey group" indicatorGap="4"/>
<mx:FormItem label="priority" indicatorGap="4" width="100%">
<mx:HBox horizontalGap="1">
<mx:Button label="-" click="{group2Group.priority--}" width="20"/>
<mx:TextInput text="{group2Group.priority}" editable="false" width="30"/>
<mx:Button label="+" click="{group2Group.priority++}" width="20"/>
<mx:Spacer width="10"/>
<mx:CheckBox id="cb1" selected="{group2Group.enabled}" change="{group2Group.enabled=cb1.selected}" label="enabled"/>
</mx:HBox>
</mx:FormItem>
<mx:FormItem indicatorGap="4" width="100%">
<mx:Button label="setHotKeyFocus" click="{group2Group.setHotKeyFocus()}"/>
</mx:FormItem>
</mx:Form>
<mx:Form width="100%">
<mx:FormHeading label="popup hotkey group" indicatorGap="4"/>
<mx:FormItem label="priority" indicatorGap="4" width="100%">
<mx:HBox horizontalGap="1">
<mx:Button label="-" click="{popupGroup.priority--}" width="20"/>
<mx:TextInput text="{popupGroup.priority}" editable="false" width="30"/>
<mx:Button label="+" click="{popupGroup.priority--}" width="20"/>
<mx:Spacer width="10"/>
<mx:CheckBox id="cb2" selected="{popupGroup.enabled}" change="{popupGroup.enabled=cb2.selected}" label="enabled"/>
</mx:HBox>
</mx:FormItem>
<mx:FormItem indicatorGap="4" width="100%">
<mx:Button label="setHotKeyFocus" click="{popupGroup.setHotKeyFocus()}"/>
</mx:FormItem>
</mx:Form>
</mx:VBox>
</mx:Panel>
</mx:Application>