Products
Technologies

Developer resources

Displaying a hand cursor when the user rolls over the CheckBox control in Flex

Avg. Rating 2.8

Problem

You want to change the mouse cursor to a hand cursor when the user moves their mouse over a CheckBox control in your Flex application.

Solution

The following example shows how you can display a hand cursor when the user rolls their mouse over the Flex CheckBox control by setting the useHandCursor and buttonMode properties.

Detailed explanation

 <?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/15/displaying-a-hand-cursor-when-the-user-rolls-over-the-checkbox-control-in-flex/ --> <mx:Application name="CheckBox_useHandCursor_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
 
    <mx:CheckBox id="checkBox"
            label="useHandCursor"
            useHandCursor="{checkBox.selected}"
            buttonMode="true"
            selected="true" />
 
</mx:Application>

You can also set the useHandCursor property using ActionScript, as seen in the following example:

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/15/displaying-a-hand-cursor-when-the-user-rolls-over-the-checkbox-control-in-flex/ --> <mx:Application name="CheckBox_useHandCursor_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
 
    <mx:Script>
        <![CDATA[
            private function checkBox_change(evt:Event):void {
                checkBox.useHandCursor = checkBox.selected;
            }
        ]]>
    </mx:Script>
 
    <mx:CheckBox id="checkBox"
            label="useHandCursor"
            useHandCursor="true"
            buttonMode="true"
            selected="true"
            change="checkBox_change(event);" />
 
</mx:Application>

For more information, see "Displaying a hand cursor when the user rolls over the CheckBox control in Flex" at FlexExamples.com.

Report abuse

Related recipes