One of the things people looked for quite often in Lists was the ability to click on a specific element within a ListCellRenderer to get an event specific to that element. E.g. a list with X's drawn on the side to remove the element.
In the past we contended that since the list is stateless its impossible for us to provide such information and recommended people use a Container with items. We now have a solution which works only for touch devices, this feature allows adding a listener to a component within the renderer which will now trigger an event if the component is touched.
Notice that the component will not contain the right data since the list selection indicates the actual selection, however if you add a listener to a button containing the X you should get an action event on that button before the list action event. This will allow you to toggle a flag indicating that the X was pressed and not a different portion of the renderer.
This isn't ideal but since the list is stateless this is the best we could come up with.
Assuming you used the GUI builder & GenericListCellRenderer you can use the method GenericListCellRenderer.extractLastClickedComponent() in the action listener for the list to get the button that was pressed to generate this event or null if no button was pressed.
I apologize for the lack of videos recently, we are working very hard towards a LWUIT release in June (hopefully, bureaucracy is always our foe) so I don't have quite the same amount of cycles to dedicate for proper blogging. I'll try to get something decent going soon.
Wednesday, May 25, 2011
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment