Flex Combobox: Cancel Select - apache-flex

I've made an itemrenderer for the combobox control that shows a button next to the label.
If a user clicks this button, the item gets removed from the dataprovider. Works so far.
When he selects an item, the combobox closes, that's ok. But I don't want it to close when he removes an item.
So is there a way to cancel the change event?
I have tried several things, but to no avail.
I have to use the combobox for layout reasons, don't have enough space to use listboxes...
Thanks for your help.

In your custom itemrenderer , on mouse down handler stop Immediate Propogation
event.stopImmediatePropogation();

In your custom item renderer, try canceling the event in your button's click handler.
event.stopImmediatePropogation()

Related

Difference between focus, focusleave,focusenter with extjs

Can anyone explain me what the difference between focus, focusleave and focusenter on button method with extjs, I'm lost because it seems to be the same when I add event listener. Thanks
kind regards
difference between focus, focusleave and focusenter on button method
with extjs
Method? I guess you mean the events right? Cos:
The focus method will focus your button when you call it.
As you can see on the picture the middle button has focus, you can change the focus on the webpage usually by using TAB key. ExtJS supports full control over your app using keyboard.
The focus, focusenter, focusleave events. If you are not sure what to use - just use "focus"
The focus event should be clear - it's simply fired when the button has focus.
The focusenter is fired when the component get's focus but as the docs states it's also fired in the whole component hirearchy. That means that if the button is in panel which is in view and you focus the button - the focusenter will be fired on the view, panel, button.
main -> panel -> button
Events
The focusleave is the same as focus enter. Fired when focus is lost on the component - again fired in the whole hirearchy. So if the focus went completly away form the page you would see focus leave on the button -> panel -> view

How to set the old value which was selected earlier, after a value change event fired

I am facing a problem like I have one Vaadin ComboBox with preselected value.I am changing the value from the ComboBox to another value,then ValueChangeEvent is fired.Inside the valueChange method I have written something to show a Popup Window which has Cancel and Ok button.Upon clicking on OK button of Popup Window I am going with the changed value of the ComboBox but upon clicking on Cancel button I just want to have the old value which was there before value change event fired.
Could anyone please help me out from the above issue?
Thanks in advance.
Maybe you can save whatever SelectedItem the combobox has when the event is fired, and if the user pressed cancel, you reset it to this stored item.
Before the click, how do you know what is selected in the click? Of course, you need to store the current selection somewhere. Lets call it currentSelectedValue (it could be NULL in the begining)
On click, you have a new selection, lets call it newSelectedValue
Now, if you do not want to go with this newSelectedValue, simply do this:
combo.setValue(currentSelectedValue);

Flex focusOut event on TextInput and pop-up does not remove focus?

I have a flex app with several fields and one text field with a focusOut event:
<mx:FormItem label="Last" x="226" y="1">
<s:TextInput id="lastNameClientTextInput" text="#{_currentEditClient.lastName}" change="textFieldChangeCapitalize(event)" focusOut="lastNameClientTextInput_focusOutHandler(event)"/>
</mx:FormItem>
As expected, when I tab or click out of the field after typing a value it executes my "lastNameClientTextInput_focusOutHandler" method which simply pops-up a new window:
protected function lastNameClientTextInput_focusOutHandler(event:FocusEvent):void
{
clientSearchPopUp = new ClientListWindow();
PopUpManager.addPopUp(clientSearchPopUp, this, true);
PopUpManager.centerPopUp(clientSearchPopUp);
}
That window will do a "PopUpManager.removePopUp(this);" when the user clicks the close button.
However, the problem is when the window closes, the focus is back on the lastNameClientTextInput! I am unable to click or tab out of the field!
When I tab out I do initially see the ibeam cursor move from the last name field to the next field in tab order (address) and then my window pops-up. When I close the window it moves BACK to the last name field and highlights the value.
It is as if I need to do something to validate the focusOut event?
You might want to try using valueCommit rather than focusOut. You could also listen for the popup being removed and set focus manually.
HTH;
Amy
Late I know, but Flex may be referring to the FocusManager.lastFocus property to resume focus from the last time the component was active. When triggering the pop up, try calling:
(focusManager as FocusManager).mx_internal::lastFocus = null;

Flex: ItemEditor losing focus!

Here's an image of what my problem is:
I am using a combo-box as a Datagrid ItemEditor (Not just Renderer, my Renderer is a Label, double clicking on a cell makes the combo-box visible, as is the case with all item editors)
Now, selecting one of the entries in the combo-box is no problem. But my problem is only when i select the "Fruit" , which in turn pops open another layer called "Select Fruit" dialog
Questions:
How do i keep item editor, while the focus is on the layer; right now as soon as i click on the fruit , my handler popsup the "Select Fruit" dialog and the focus is on the layer. Once the focus goes out of the editor, the ItemEditor goes away and ItemRenderer label comes back.
I want to keep the ItemEditor alive! where do I hook up interms of events like begin/end ItemEdit etc?
You can keep your itemEditor alive by listening for DataGridEvent.ITEM_EDIT_END. Then you have a lot more control to do what you want. Some FYI from my blog:
DataGridEvent.ITEM_EDIT_END
- Dispatched when focus is removed from the cell
- List-based control’s default event listener will
1) use the .editorDataFrield property to deterine the property of the item editor to store the edited data; In a default TextInput control’s item editor, the “text” property would contain the new data.
2) Invoke destoryItemEditor() depending on the reason of the event
You can interrupt the default List-based control’s default event listener by using event.preventDefault() to
a) Modify the data returned from the item editor
b) Examine/Validate the data entered into the item editor; If the data is incorrect, you can halt Flex passing the data back from the item editor into the list-based control
http://knowledge.lapasa.net/?p=153
Try losing focus of your ItemEditor. Goto Combo Box Change Listener
protected function comboBox_changeHandler(event:ListEvent):void
{
// set focus out event on datagrid. Its like clicking outside the datagrid
event.target.parent.parent.parent.dispatchEvent(new FocusEvent(FocusEvent.FOCUS_OUT);
}

Flex 3 TileList selected item strange behaviour

I have a Flex TileList with an itemRenderer made by me.
The list loads the content perfectly and renders it.
Renderer is a simple canvas element with a checkbox and another canvas with some labels with data.
I implemented a method that, on TileList itemClick="clickedItemHandler(event)", changes the state of the checkbox (if checked -> uncheck, and vice versa).
Problem is: the method works if i click on any place of the item, EXCEPT the checkbox. When i click the checkbox, it doesn't change state.
My thoughts: maybe i was changing the state of the checkbox, and the event changing it back, but i debugged it and it doesn't look like so..
The solution is actually quite simple. Perhaps the best way to make this work is making sure the CheckBox ignores mouse clicks, and this can be done by setting the "mouseEnabled" attribute to false.
Cheers
I think you're probably correct. The checkbox toggles when you click it and then you toggle it back when the event gets to the TileList. You may not see this when debugging depending on how you are confirming... you may be able to fix this by confirming that the target of the event is not a CheckBox.

Resources