Question

I'm writing a Flex application and I came across what I think is a weird problem.

I want to create a text box and a DateChooser as the datefield didn't do what I wanted and it's Halo so I can't skin it easily. I want the DateChooser to show when I click on the text input. Here is an except from my code:

    <s:TextInput id="wholeDate" width="100"  
                 mouseOver="stopChangeToNormal();"
                 paddingRight="10"
                 click="date1.visible = true"
                 focusOut="date1.visible = false"/>
    <s:Button label="Go" width="70" />
</s:Panel>

<mx:DateChooser id="date1" 
                visible = "false"
                change="useDate(event);" 
                mouseOver="changeToNormalState = false;" 
                y="{wholeDate.y + buttonsGroup.y + 20}"
                x="{wholeDate.x + buttonsGroup.x - 175 }" />    

The weird thing is that it works if I make it visible = "true" to start, but if I have it visible="false" it doesn't work! It shows, but the date I select doesn't show in the box as it does if I have it as visible="true", but I don't want it to be visible initially.

Any ideas?

Was it helpful?

Solution

I don't think its actually anything to do with the initial visibility of the DateChooser. Have you verified that your event handlers are indeed called, and in an order that makes sense? The problem appears to be that when you attempt to make a selection in the DateChooser, the TextInput gets a focusOut event, which hides the DateChooser, which apparently prevents it from receiving the selection event. I think you need to be more selective about when you actually hide the DateChooser. Perhaps you need to defer the hiding so it has a chance to respond to the selection first.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top