Pergunta

here is my datefield:

<mx:DateField id="date" 
    formatString="DD-MM-YYYY" selectableRange="{DTselectableRange}" 
    change="handleChange()" editable="true"  clear="dateCleared(event)"/>

i want to detect clear event, adobe ref say:

clear Event is dispatched when the user selects 'Clear' (or 'Delete') from the text context menu.

but dateCleared function in never called...I need it beacause I have to set selectedDate to null when user delete it...

Please help me...

Foi útil?

Solução

I can confirm that mx.controls.DateField does not dispatch a clear event when selecting "Delete" from the text content menu. I've also had no luck getting a clear event to be dispatched for editable mx.controls.TextInput and spark.components.TextInput. Hmm....

What you can do is handle a change in the value of the control in your handleChange event listener and set your selectedDate value there.

Something like this:

private var selectedDate:Date;

private function handleChange(date:Date):void {
    if (date == null) {
        selectedDate = null;
    }       
    // your existing handleChange code here
}

Also, I would change this:

<mx:DateField change="handleChange()" />

to this

<mx:DateField change="handleChange(DateField(event.target).selectedDate)" />
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top