Still not too much to do on that. All the functionality appears to be in
the close function. I've kludged up this to do what you want. There's a
"_calling" variable in there as the close function gets called twice on
every change (for reasons I don't care to examine) that'll allow it to
dispatch the change event once per frame.
package
{
import flash.events.Event;
import mx.controls.ComboBox;
import mx.events.ListEvent;
public class ComboBoxNoClose extends ComboBox
{
private var _calling:Boolean = false;
public function ComboBoxNoClose()
{
super();
}
public override function close(trigger:Event = null):void
{
if (trigger != null)
super.close();
else if (dropdown != null && !_calling)
{
_calling = true;
dispatchEvent(new ListEvent("change"));
callLater(function():void { _calling = false} );
}
}
}
}
--- In [email protected], "Sascha" <sbal...@...> wrote:
>
> My problem is that writing a whole custom component is too involved
for the
> few time I have and your method seems to work quite well.
>
>
>
> The only trouble I have (as described in my previous reply) is that
the
> ComboBox should fire a change event everytime an item is selected
while it
> stays opened. By default the ComboBox is only firing this event after
it
> closes.
>
> However listening to the dropdown (the List component in the ComboBox)
> property's ListEvent.CHANGE seems not to cut it. It would be great if
you
> would have a workaorund for this!
>
>
>
> Best,
>
> Sascha
>
>
>
>
>
>
>
> From: [email protected] [mailto:[email protected]]
On
> Behalf Of Ben Reynolds
> Sent: Thursday, April 16, 2009 14:23
> To: [email protected]
> Subject: [flexcoders] Re: Making ComboBox stay open after item select?
>
>
>
> I'm by no means on Alex's level of Flex knowledge, but a Button
combined
> with a Menu component would work too. You wouldn't get into resizing
issues
> and you'd still be able to do styling without resorting to UIComponent
first
> principles. :)
>
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> ,
> "Sascha" sbalkau@ wrote:
> >
> > I've made a short test and that seems to work so far. Thanks for the
hint
> > Ben!
> >
> > I almost started to try writing a custom component from a Button and
a
> List
> > wrapped into a UIComponent as Alex Harui suggested in a message I've
found
> > but seems that that's not necessary.
> >
> >
> >
> > Sascha
> >
> >
> >
> >
> >
> > From: [email protected]
<mailto:flexcoders%40yahoogroups.com>
> [mailto:[email protected]
<mailto:flexcoders%40yahoogroups.com> ]
> On
> > Behalf Of Ben Reynolds
> > Sent: Thursday, April 16, 2009 10:34
> > To: [email protected] <mailto:flexcoders%40yahoogroups.com>
> > Subject: [flexcoders] Re: Making ComboBox stay open after item
select?
> >
> >
> >
> >
> >
> >
> >
> >
> > Something like:
> >
> > package
> > {
> > import flash.events.Event;
> > import mx.controls.ComboBox;
> >
> > public class ComboBoxNoClose extends ComboBox
> > {
> > public function ComboBoxNoClose()
> > {
> > super();
> > }
> >
> > public override function close(trigger:Event = null):void
> > {
> > if (trigger != null)
> > super.close();
> >
> >
> > }
> > }
> > }
> >
> > --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> ,
> "Sascha" <sbalkau@> wrote:
> > >
> > > Does anyone know how to modify the ComboBox so that it stays open
after
> > > selecting an item?
> > >
> > > I need such a ComboBox for a client that opens/closes only if the
user
> > > clicks on the 'header area' of the ComboBox or that closes only if
> clicked
> > > outside the ComboBox.
> > >
> > > The use case for this is that the ComboBox will have custom item
> renderers
> > > that contain (for example) a CheckBox and a Label and the user
should be
> > > able to make several selections without the ComboBox closing
inbetween.
> > >
> > > I've made this before by wrapping all the stuff into a Panel and
> changing
> > > the Panels height on close so that only the header is visible but
that
> > > method is rather suboptimal, especially for skinning.
> > >
> > > Would be great if somebody has a workaround for this!
> > > Thanks in advance!
> > >
> > > Sascha
> >
>