2
votes

Please note the remark mentioned WORKAROUND at the end of this question.

Based on a Dictionary based specification, one of my classes creates a Form programmatically.

Adding TextInput or DatePicker to FormItemss works as expected.

Unfortunately, the following code just creates a colored rectangle, not the actual picker:

ti = new ColorPicker();

ColorPicker( ti ).selectedColor = TAColor( _spec[ key ].value ).color;

and later on

formItem.addElement( ti );

The Form is embedded in a TitleWindow component presented using

PopUpManager.addPopUp(...);

When added to TitleWindow, it shows up correctly, within Form->FormItem not:

enter image description here

I can't image, why the picker doesn't appear. Do you?

WORKAROUND:

If I wrap the ColorPicker inside a Group things work:

ti = new Group();
Group( ti ).addElement( new ColorPicker() );

In this case, the ColorPicker appears as editable.

Still, I'd be too happy to learn what the problem with my initial solution. Bug?

2
That's definitely weird. I've tried to programmatically add a ColorPicker to a spark Form, and it does just what you explain... It does work properly though with an MX Form. I'm strongly suspecting the FocusManager. - LoremIpsum
As you explained, DateField or DatePicker work perfectly. The sources of ColorPicker are included in FlashBuilder 4.5.1. I not going to patch them. But if I would, would FlashBuilder recompile and add them to my binary? - SteAp
Nope, you have the source but it's not what is used to run your apps, and, besides, you don't want to recompile thee entire framework. I suggest you to extend the component and try to patch it. I've tried this by myself, but couldn't find any workaround... - LoremIpsum

2 Answers

1
votes

A DateField (which extends ComboBase like ColorPicker) behaves properly in a spark Form. But in the ColorPicker, the mouse down handler of the button never gets called. I think that maybe the skin part that handles the mouse clicks (it must be a button) is not properly dimensionned, and the result is it is not shown. I've come to this conclusion because within an mx Form, the ColorPicker doesn't display as it does when it is added to the regular displaylist...

Hope this helps...

0
votes

In the code you've provided, you never add the colorPicker as a child to any parent container; as such it will never show up anywhere.

You probably need to do something like:

formItem.addChild(ti ); 

[or for a Spark formItem]:

formItem.addElement(ti ); 

I'm confused as to why you're seeing a rectangle.