Tuesday 26 May 2009

ComboBox in TitleWindow Header

I am elaborating this example by using a ComboBox, but any other appropriate component can be added to the header of a TitleWindow ( say Buttons for example)

To add a ComboBox to the TitleWindow, you would need to override the function createChildren() of TitleWindow. Then you would need to add the ComboBox under TitleWindow's titleBar.
Hence write a new class, say ComboTitleWindow and extend TitleWindow.You would need to position the ComboBox according to your convenience. I positioned it such that it would just start after the TileWindow title, but if the title is so long that it would push the ComboBox out of the TitleWindow, it would be positioned over the title.


public class ComboTitleWindow extends TitleWindow
{

public function ComboTitleWindow()
{
super();
}

private var combo:ComboBox=new ComboBox();

override protected function createChildren():void
{
super.createChildren();
this.combo.width=100;
this.combo.height=20;
this.combo.visible=true;
this.combo.includeInLayout=true;
super.titleBar.addChild(this.combo);
positionChildren();
}

public function positionChildren():void
{
this.combo.y = 5;
if(super.titleTextField.measuredWidth+120<this.unscaledWidth-30)
this.combo.x = super.titleTextField.measuredWidth+20;
else
this.combo.x = this.unscaledWidth-130;
}
}

No comments:

Post a Comment