Hello,
I was working with one of my applications and there is a need for the user to select specific items that appear in a ListView. However, even after enabling the hasCheckboxes attribute in the ViewComposer, checkboxes do not show up in the view. Previous post show that other developers have encountered this issue. Does someone have code to handle this scenario in Package form or Source that can be loaded into an image? It would be a great help as I don't have the time to properly research the problem and create a solution. Regards, Pax |
Pax wrote:
> I was working with one of my applications and there is a need for the > user to select specific items that appear in a ListView. However, even > after enabling the hasCheckboxes attribute in the ViewComposer, > checkboxes do not show up in the view. That's because the checkbox stuff in windows doesn't work unless the ListView has its #isVirtual set to false (which it won't have by default). Change that (in the VC or from code) and the check boxes should appear. After that you can retrieve the setting of the flag with methods like the following (added to ListView): ============================ isItemChecked: anObject "Answer whether the entry for anObject is checked." | index | #CUadded. index := self handleFromObject: anObject ifAbsent: [^ false]. ^ self isItemCheckedAt: index. ============================ isItemCheckedAt: anIndex "answer whether the entry at the given index is checked" | stateFlags | #CUadded. stateFlags := self lvmGetItemState: anIndex - 1 mask: LVIS_STATEIMAGEMASK. ^ (stateFlags bitShift: -12) = 2. ============================ (I think that LVIS_STATEIMAGEMASK is defined in Win32Constants by default, if not then its value should be 16rF000) Note that making a ListView non-virtual will make it consume more resources and be significantly slower if you are using it to display large lists. If you need to track changes to the "checked" state as they occur then that is probably possible too, but off-hand I don't know how to do it. If I needed that degree of flexibility (or wanted to avoid non-virtual ListViews) then I'd probably not use the Windows built-in check-box stuff at all, but would use a multi-column EditableListView with embedded CheckBoxes. John Aspinall's EditableListView can be downloaded from the Solutions Software website: http://www.solutionsoft.co.uk/ Other approaches are possible too, but since John's stuff is very easy to use, that's what I'd normally go for. -- chris |
In reply to this post by pax
"Pax" <[hidden email]> wrote in message
news:[hidden email]... > I was working with one of my applications and there is a need for the > user to select specific items that appear in a ListView. However, even > after enabling the hasCheckboxes attribute in the ViewComposer, > checkboxes do not show up in the view. Chris has covered most important approaches, but sometimes just flipping an icon (True.ico and False.ico) for the item in the list can be effective. rush -- http://www.templatetamer.com/ http://www.folderscavenger.com/ |
Chris,
thanks for the help. I'll file in the code and have a go at it. Fortunately, the application of check boxes in the ListView is for a finite number of objects... No more than say 20 items. I would rather have such a feature (checkboxes) opposed to opening up additional dialogs to add/remove objects on the fly. Rush, I'll have a look at the links you provided for additional tips. Regards, Pax |
"Pax" <[hidden email]> wrote in message
news:[hidden email]... > Rush, I'll have a look at the links you provided for additional tips. oups, links are not additional tips, they are part of my signature :) My tip can be expressed in one paragraph - catch double click on list item, and change the state(selected/deselected) of the list item., call itemUpdated. Implement icon method of list items so that it returns one icon when item is in selected state, and another when it is deselected. icon self selected ifTrue: [^ True icon] ifFalse: [^ False icon]. if you do not intend to deploy, this could be shortened to: icon ^self selected icon For advices on how to catch the double click see thread "Overiding the double click *" started by me a few weeks ago. rush -- http://www.templatetamer.com/ http://www.folderscavenger.com/ |
Ah...
I think I need to make some cawfee... Been working many hours and I could be looking at Chinese text and not even notice. :) |
In reply to this post by rush
rush wrote:
> For advices on how to catch the double click see thread "Overiding the > double click *" started by me a few weeks ago. For ListViews, as opposed to TreeViews, you can simply set a handler for the #actionPerformed event. No need for subclassing. -- chris |
Free forum by Nabble | Edit this page |