[flexcoders] Get drop parent for Tree in dragOver?
I want to have a tree with a single level of folders, each with 0 or more child nodes. The folders can be reordered, as can the children, and while the children can be moved between folders, there is no nesting (and children have to always be in a folder). I've been having so many troubles with this it's not funny, but to keep this post simple, is there a way to identify which parent a node will be under, in the dragOver handler for a Tree component? Most of the code I have seen is something like: private function handleDragOver(event:DragEvent):void { dropIndex = event.currentTarget.calculateDropIndex(event); dropNode = event.currentTarget.indexToItemRenderer( dropIndex ); } which will get the new index and the node currently in that index. However, these are just to do with which node the cursor is over - they both give the same reading when I drag a child to be at the end of one folder list, or just outside that folder altogether. Looking in the Tree.as source I guess that _dropData.parent is what I am after, but this is a private property. Any ideas?
[flexcoders] Re: Get drop parent for Tree in dragOver?
Well, it's the same index, but it certainly isn't the same thing. Moving an item to be the last in a list in a folder is not the same as placing it outside of the folder. But they both have the same index (as the tree list is seen as a flat list as far as index is concerned). But thanks for that link - I didn't realise that accessing a private member would be as simple as: public function get dropData():Object{ return super.mx_internal::_dropData; } Unfortunately that Tree has very flaky drag drop support with a small sample array (their example from XML seems fine though). But I can subclass Tree with just that function above and it should be fine. Thanks again. --- In flexcoders@yahoogroups.com, benoit.kogut [EMAIL PROTECTED] wrote: Because trying to drop an item after the last node of a branch is seen as trying to drop it outside the branch (actually, right below the branch). The dropData property can be made accessible, check the source of the Tree with spring loaded folders. http://flexibleexperiments.wordpress.com/2007/02/26/flex-201-tree-with-spring-loaded-folders-update-2/
[flexcoders] Re: Datagrid editable cell loses focus on screen update
Thanks Alex, setting a fixed size on the label fixes the issue. Now it's a problem for the designers :P --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: Fixing the size of the label might prevent an entire update. You can also subclass and block as well.
[flexcoders] Re: Datagrid editable cell loses focus on screen update
Well, if I remove the error message text binding (so the validation errors do not display), then the data in the grid is still reverted ok, and I don't lose the edit session. So it's definitely to do with the text updating - I imagine because this causes a re-layout of the whole screen, which resizes the grid (even if it doesn't actually change size). Grant --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: In Flex 2 it was deemed too tricky to maintain the edit session while it could be jumping around due to screen updates, so we kill the session. Not sure why updating outside the DG causes the DG to lose focus. Are you sure there isn't a collection change going on as well as you revert data or something like that? You may need to not commit the data to the collection until after validation. The next Moxie Beta takes a stab and trying to maintain the edit session.
[flexcoders] Datagrid editable cell loses focus on screen update
I have a datagrid with editable cells. When the user changes a value this is saved to the server. When the server identifies a validation error on the new data, their change is undone, and a warning message is shown outside of the grid. Unfortunately, showing this warning message outside of the grid (updating the text attribute of a Label), will always cause the currently editing cell to lose focus. In fact, anything that updates the screen will do this. This can be annoying, as I want other screen elements to update etc (without becoming focussed themselves), but not taking the focus away from what the user is currently editing. Any ideas?
[flexcoders] Re: Datagrid editable cell loses focus on screen update
Perhaps in general it is best to also have client side validation, but in this case each column can have custom validation rules (including unique, which needs to compare all other data). This needs to be (and already is) validated on the server side, and would be non-trivial to add to the client. Besides, it's not just the validation errors (although they are more common). Any other small screen update that updates text elements also removes the editor focus (ie current status, log messages - these run asynchronously in the background). Grant --- In flexcoders@yahoogroups.com, Scott - FastLane [EMAIL PROTECTED] wrote: In general it seems it would be preferable to validate user input on the client side... if you did this you could use the errorString of the itemEditorInstance to show the error to the user without having to wait for the back end, etc. When you do this the error is shown in the cell where the invalid value was entered (it's a pretty nice feedback mechanism). The following is a code snippet from a DataGrid itemEditEnd event handler where check with a CurrencyValidator to see if user input is valid... if not the errorString is set. var valueStr:String = event.currentTarget.itemEditorInstance.text; var result:ValidationResultEvent = this.currencyValidator.validate(valueStr, true); if(result.results != null result.results.length 0) { event.currentTarget.itemEditorInstance.errorString = Value must be valid currency. ($ddd.cc) dollar sign is optional.; event.preventDefault(); } else { //commit the user edited value... } hth Scott grantdotcox wrote: I have a datagrid with editable cells. When the user changes a value this is saved to the server. When the server identifies a validation error on the new data, their change is undone, and a warning message is shown outside of the grid. Unfortunately, showing this warning message outside of the grid (updating the text attribute of a Label), will always cause the currently editing cell to lose focus. In fact, anything that updates the screen will do this. This can be annoying, as I want other screen elements to update etc (without becoming focussed themselves), but not taking the focus away from what the user is currently editing. Any ideas?
[flexcoders] Re: Flex Component Kit for Flash CS3 - item not showing
I've only made a few components using the Flex Component Kit, but none of them display in Flex Builder design view. As they work in the compiled swf I assumed that was the expected behaviour... ? Jurgen - What MXML? The component kit creates SWC files...
[flexcoders] Re: Fluid layout? Refresh container / component size?
Question, why do you have a Panel inside a canvas inside a popup? No reason, just the MXML component defaulted to Canvas, and I put a Panel in there for aesthetic reasons. I have changed the root node of the component to a Panel now :) Anyway, it appears the issue is because the popup actually contains a HDividedBox, and the component is in there. And it's the HDividedBox that does not resize automatically (without it theres no resize problem). I'll look into what controls this container type has, but in case anyone has any suggestions the pseudocode is: GroupsComponent.mxml Panel HBox id=controls ...input fields, buttons etc ... /HBox Button click=showHide()/ /Panel where the controls HBox is shown/hidden with addChild/removeChild based on the button click. PopupWindow.mxml Panel HDividedBox GroupsComponent / AnotherComponent / /HDividedBox /Panel And the problem is that changes to the size of GroupsComponent does not automatically update the size of the HDividedBox. Having code to addChild/removeChild to the HDividedBox does then cause the size to be read correctly. Regards, Grant Cox
[flexcoders] How to structure states for a number of subtle changes?
I am looking for some guidance on how to structure states, for forms that can have a number of subtle overlapping changes. For example, a form to add/edit a simple data type: mx:Panel title=Edit mx:Form mx:FormItem label=Title: mx:TextInput id=titleField/ mx:Label text=Title error goes here id=titleError/ /mx:FormItem mx:FormItem label=Type: mx:ComboBox id=typeCombo/mx:ComboBox /mx:FormItem mx:FormItem label=New Type: mx:TextInput id=newTypeField/ /mx:FormItem mx:FormItem mx:Button label=Update id=saveButton/ /mx:FormItem /mx:Form /mx:Panel This form can either be used to create a new object (panel title Create New, button title Save), or edit an existing object (panel title Edit, button title Update). The newTypeField should only show if create_new was selected in the typeCombo. When the saveButton is clicked, the button should be disabled and its title should change to Processing If the save succeeds, the form should be replaced with a success message. If the save fails, then an appropriate error message should appear next to the invalid fields (ie the title error could be Please provide a title, Title should be alphanumeric characters only, Title already taken, please choose another etc). All fields may have an error message, and I only want the error text to show (and take up any space) if there is an error. Can this be done with states? Most of these options are not exclusive - they could happen regardless of any of the other state changes. If not with states, how would you recommend it be done?
[flexcoders] Fluid layout? Refresh container / component size?
I'm fairly new at Flex, and having some problems with getting containers and components to automatically resize to fit their contents - when these contents are a custom component (separate mxml file). I have a component (GroupsList), based on Canvas with a number of containers inside (Panel, HBox, VBox etc). These will be added / removed based on what controls the user interacts with (using addChild, removeChild). None of the containers in this component have widths or heights set, so they correctly just fit around whatever content is showing. Now, I have this whole GroupsList component inside another component, GroupsPopup. This component displays the above component and a few additional buttons and controls. The containers in this also have no widths or heights set. When this GroupsPopup is first shown, it correctly sizes to fit the displaying GroupsList content (plus the other buttons etc). However, as the GroupsList changes size due to interaction, the GroupsPopup does not respond - making the GroupsList impossible to use. I have made the inner component dispatch an event to call invalidateSize(), invalidateDisplayList() etc, but this does not cause a resize. If the outer component has a addChild/removeChild call then it does, but this seems highly inappropriate to use just for forcing a resize. Can anyone shed any light on this?