Stop Dragging TitleWindow

I was under a bit of time pressure and trying to stop dragging of a TitleWindow PopUp. I tried all sorts of funky stuff like intercepting the onMouseDown Event and using Event.stopImmediatePropogation() to no avail. I also wanted access to the titleBar exclusively so here is an extended TitleWindow which enables both my requirements and stops the dragging of a TitleWindow.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.newtriks.view.components.utils
{
  import flash.events.MouseEvent;
  import mx.containers.TitleWindow;
  import mx.core.IUIComponent;
  import mx.core.UIComponent;

  public class PopUpTitle extends TitleWindow
  {
      public function PopUpTitle()
      {
          super();    
      }
      
      override protected function startDragging( event:MouseEvent ):void
      {
      }
      
      override protected function updateDisplayList( unscaledWidth:Number, unscaledHeight:Number ):void
      {
          super.updateDisplayList( unscaledWidth, unscaledHeight );
          if ( numChildren )
          {
              var child:IUIComponent = IUIComponent( getChildAt(0) );
              child.setActualSize( unscaledWidth, child.getExplicitOrMeasuredHeight() );
          }
      }
      
      public function getTitleBar():UIComponent
      {
          return super.titleBar;
      }
  }
}

Comments