views:

666

answers:

2

Similar to the XP login screen, in Flex 3, how can I display a warning to the user in a textbox that the CAPS LOCK key is enabled?

+1  A: 

In actionScript:


if(flash.ui.Keyboard.capsLock){
    // caps lock is on...
}

or MXML:


<mx:Box width="100%" id="capsbox"
    visible="{flash.ui.Keyboard.capsLock}" 
    includeInLayout="{capsbox.visible}">
        <mx:Text text="Caps Lock is on." color="red" />
</mx:Box>

mmattax
I created a blank form and dropped it on the form. It doesn't work, even if CAPS LOCK is on when I start the app. Do I need a keyboard handler?
+2  A: 

flash.ui.Keyboard.capsLock is not bindable so that code won't really work.

I would invoke a function in the "keyDown" event for the TextInput and then check flash.ui.Keyboard.capsLock in that function. You can then set visible/includeInLayout on that Text, pop up an Alert, etc...

cliff.meyers