Someone else posted this same question to the list a while ago, I
extended TitleWindow to create an undraggable version. It's a pretty
simple extension, I went with intercepting the mousedown event on the
titleBar. Not sure if I had a reason for doing that instead of
overriding the startDragging method as already suggested.

But anyway, here's my code (or if it's hard to read in the email you
can go here:
http://dougmccune.com/PanelTest/bin/srcview/source/com/dougmccune/containers/UndraggableTitleWindow.as.html)

package com.dougmccune.containers
{
    import flash.events.MouseEvent;
    import mx.containers.TitleWindow;
    import mx.controls.Button;
    
    public class UndraggableTitleWindow extends mx.containers.TitleWindow
    {
        
        
        override protected function createChildren():void
        {
            super.createChildren();

            titleBar.addEventListener(MouseEvent.MOUSE_DOWN,
stopEvent, false, 1);
        }
        
        private function stopEvent(event:MouseEvent):void {
            
            if (event.target is Button) {
                super.dispatchEvent(event);
                return;
            }
                
            event.stopImmediatePropagation();
        }
    }
}


--Doug


--- In flexcoders@yahoogroups.com, "Michael Schmalle"
<[EMAIL PROTECTED]> wrote:
>
> Hi,
> 
> Without getting into the mx_internal namespace, this is an option;
> 
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:TitleWindow
>     xmlns:mx="http://www.adobe.com/2006/mxml";
>     layout="absolute"
>     width="400" height="300">
> 
>     <mx:Script>
>         <![CDATA[
> 
>             private var _draggable:Boolean = false;
> 
>             /**
>              * Determines if the title window is draggable.
>              */
>             public function get draggable():Boolean
>             {
>                 return _draggable;
>             }
> 
>             /**
>              * Determines if the title window is draggable.
>              */
>             public function set draggable(value:Boolean):void
>             {
>                 _draggable = value;
>             }
> 
>             /**
>              * Override the dragging method to block drag.
>              */
>             override protected function
startDragging(event:MouseEvent):void
>             {
>                 if (_draggable)
>                 {
>                     super.startDragging(event);
>                 }
>             }
> 
>         ]]>
>     </mx:Script>
> 
> </mx:TitleWindow>
> 
> 
> Other than the above for a custom mxml component, this is about the
best you
> can get becasue the titleBar property is protected.
> 
> Peace, Mike
> 
> On 11/30/06, Roman Protsiuk <[EMAIL PROTECTED]> wrote:
> >
> >   Hi, everyone.
> >
> > I guess there is some way to make TitleWindow not draggable, isn't
there?
> > Tried
> > titleBar.mouseEnabled = false;
> > that didn't help.
> >
> > Any ideas?
> >
> > Thanks,
> > R.
> >  
> >
> 
> 
> 
> -- 
> Teoti Graphix
> http://www.teotigraphix.com
> 
> Blog - Flex2Components
> http://www.flex2components.com
> 
> You can find more by solving the problem then by 'asking the question'.
>


Reply via email to