'2010/03/11'에 해당되는 글 2건

  1. ToolTip Position Manager 2010/03/11

ToolTip Position Manager

from flex 2010/03/11 18:16
<?xml version="1.0"?>
<!-- tooltips/PlacingToolTipsInContainers.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="middle" horizontalAlign="center" height="250" width="400">
    <mx:Script>
        <![CDATA[
            import mx.controls.ToolTip;
            import mx.managers.ToolTipManager;

            private var tip:ToolTip;
            private var s:String;
              
            private function showTipA(event:Object):void {
                s="My Tip A";
                tip = ToolTipManager.createToolTip(s,
                    event.currentTarget.x + event.currentTarget.width + 10,
                    event.currentTarget.y
                ) as ToolTip;
            }

            private function showTipB(event:Object):void {
                s="My Tip B";
                var pt:Point = new Point(
                    event.currentTarget.x,
                    event.currentTarget.y);
                
                // Call this method to convert the object's
                // coordinates inside its container to the stage's
                // global coordinates.
                pt = event.currentTarget.contentToGlobal(pt);
                
                tip = ToolTipManager.createToolTip(s,
                    pt.x + event.currentTarget.width + 10,
                    pt.y
                ) as ToolTip;
            }

            private function destroyTip(event:Object):void {
                 ToolTipManager.destroyToolTip(tip);              
            }            
        ]]>
    </mx:Script>

    <!-- A ToolTip at the top level. -->
    <!-- The event handler for this ToolTip does not use any special
    logic to account for whether the ToolTip is inside a container.
    But this ToolTip is not inside a container so it positions itself
    normally. -->
    <mx:TextInput id="a"
        text="Good ToolTip placement"
        width="175"
        focusIn="showTipA(event)"
        focusOut="destroyTip(event)"
    />

    <mx:VBox >
        <!-- A ToolTip inside a container. -->
        <!-- The event handler for this ToolTip accounts for the control
        being inside a container and positions the ToolTip using the
        contentToGlobal() method. -->
        <mx:TextInput id="b"
            text="Good ToolTip placement"
            width="175"
            focusIn="showTipB(event)"
            focusOut="destroyTip(event)"
        />  

        <!-- A ToolTip inside a container. -->
        <!-- The event handler for this ToolTip does not use any special
        logic to account for whether the ToolTip is inside a container.
        As a result, it positions itself using coordinates that are relative
        to the container, but that are not converted to global coordinates. -->
        
        <mx:TextInput id="c"
            text="Bad ToolTip placement"
            width="175"
            focusIn="showTipA(event)"
            focusOut="destroyTip(event)"
        />  

    </mx:VBox>
</mx:Application>
2010/03/11 18:16 2010/03/11 18:16

댓글을 달아 주세요