Decorating item renderers in custom list components - apache-flex

Has anyone had success creating a custom list component which accepts a user defined item renderer, but decorates it with another class to augment its behavior?
Examples of why this might be useful include:
catching and stopping the propagation of events or dispatching new events in place of others
incorporating behavior in the renderer to interface with other packages used by the custom component
adding expand and collapse buttons for resizing the internal renderer, etc
The idea here is to not require changing the users renderer to work with this component, so keep that in mind.

Yep, I did this with the Flextras DataSorter. The DataSorter is a customized list that acts like a Netflix Movie Queue. The user's itemRenderer contains their stuff, but our wrapper adds in the number input field, the move up button, the move down button, and the other button controls.
It is pretty much a nightmare that required a lot of heavy customization of the Flex List class.
Since you're question is a "Yes" or "No" question, I feel I've answered it. What else did you want to know?

Related

Qt event for delegate in table

Question/Issue
I tried reimplementing the event method in a custom delegate to handle clicks. The delegate is used to render table cells in a table view. However, I do not get any events for the delegate (the method is never called according to the debuger). Is there anything special I need to do so my delegate can track events (in particular mouse entering/exiting, clicks)?
Context
I would like to create my own data representation for table cells. The functionality should be close to a button, but slightly different. I read that the two options for implementing buttons in table are either setting a cell widget which supposedly has a high performance cost (I did not quite understand why) or using a delegate.
Since I want different behaviour than that of a button, and for the speed myth I decided to go with a delegate.
Mouse events are send to the QAbstractItemDelegate::editorEvent() method, even if they don't start editing of the item.
See: http://doc.qt.io/qt-5/qabstractitemdelegate.html#editorEvent

In Flex 4.5, can a DataGroup have accessibilityEnabled for all of its individual items?

I'm building a Flex app that has to be accessible and meet section 508 guidelines. Some pre-built parts of are making heavy use of DataGroup, DataGrid, and ItemRenderers. I can't get anything that was created with ItemRenderers to even receive keyboard focus, so it seems impossible to have their accessibilityProperties revealed.
Is there a trick to making focus available to an ItemRenderer? Or some alternative I could use?
SOLUTION:
I kind of stumbled across this, and I'm not entirely sure why this works, but the solution is simple. Just add implements="mx.managers.IFocusManagerComponent" into the root tag of the custom ItemRenderer, and then each item in the list will be able to receive focus and expose its accessibilityProperties.
The strange is, the Flex compiler doesn't complain if the custom renderer fails to implement the required IFocusManagerComponent methods. I don't know why, but I would speculate that these methods are implemented somewhere up the code chain, and aren't used unless a component explicity implements IFocusManagerComponent.
The only problem I'm having now is that only the visible items show their accessibilityProperties, which makes sense because ItemRenderers are only created for the visible items on screen, but I should find some way to scroll the list automaticaly if the last visible ItemRenderer loses focus.

Qt: Custom QListView and live controls

My custom QListView has delegates to paint the items. I'd like to add a live control to some of the row items (like a QLineEdit), that'll always be present in the row and will automatically scroll correctly with the list.
Since items are not widgets, I cannot assign a control to be a child of an "item", thus scrolling will leave the control in its fixed spot within the QListView widget.
Is there another way?
Is that even possible?
Normally the edit widget is created (and positioned) by the delegate when an QEvent::EnterEditFocus event occurs then destroyed when a subsequent QEvent::LeaveEditFocus occurs and the data is sent back to the model. The delegate should then repaint with the new model data.
Could you expand on what you mean by a "live" control?
Why would you want to have an edit widget constantly open? I think a better way to do this would be to create a delegate which paints the normal view (i.e. for Qt::DisplayRole) in a way which you want. Assuming you create your subclass view correctly, the delegate should still update when the model changes.
If you really want to do what you're asking though, I suspect you might be able to by:
creating your own item delegate (subclassing QAbstractItemDelegate)
reimplement createEditor() to use a QLineEdit
then use the delegate's updateEditorGeometry()
Have a read of the Delegate Classes section of the Introduction to Model/View Programming though first. The Spin Box Delegate Example and Pixelator Example are worth studying too if you haven't already.

Flex 4: Checkbox in Accordion header

I wanted to know if it is possible to add a checkbox in the accordion control.
The main idea is to have a list of selectable items (like selecting various items for checkout) and each of them should have an option to display additional information (the accordion panel).
So basically, 3 questions:
Can I have a checkbox in the accordion header?
Can I have all the panels closed from the start? So the user chooses which panel to open, and not start with one panel displayed.
Can I have multiple panels opened at the same time?
Some notes:
- I tried a header renderer option, but the checkbox was the same for all accordion headers, so it was useless.
- It would be great to avoid the use of libraries or external controls. I am aware of some of the limitations of Flex controls though.
Thanks for any help or information you can provide ! :)
If you're not dead set on using mx controls, I'd give the 4.6 list/item renderer skinning method a try.
I'd use the sparks list control and create a custom item render that's comprised of checkbox control, several nested group/border-container wrappers depending on your design/creative requirements and whatever as3 logic would be necessary to expand and contract the item renderer keyed off of the checkbox's click event or change events-- that's some of the beauty of skinning item renderers in flex 4, you can encapsulate all that dope-ass logic within renderer itself.
In any case, here's some links you might find helpful:
http://www.adobe.com/devnet/flex/articles/flex4_skinning.html
http://blog.flexexamples.com/2009/06/21/creating-a-custom-halo-accordion-header-skin-in-flex-4/
http://saturnboy.com/2009/09/flex4-component-states-skin-states/
hope this helps!

destroy open item editor or item renderer in flex

Is it possible to destroy/close open item editor or item renderer of a datagrid in different mxml page?
I heard about the functions editedItemRenderer and destroyItemEditor on Datagrid. Can I use these functions in different mxml page?
Your question is a bit confusing.
Flex Applications do not have the concept of a page in the same way that HTML does. You probably mean different views, or MXML Components.
All itemEditors are created and destroyed as needed. If you are not viewing the itemEditor on screen, then likely something else has focus and the itemEditor was destroyed automatically.
In most cases, two components should not talk to each other using anything other than their defined API. so, you can have one component dispatch an event, then it's parent listen for the event and have that parent call methods on another component [such as a DataGrid].

Resources