Page 1 of 1
ListIconGadget & checkbox states
Posted: Sun Mar 20, 2005 1:36 am
by Phant0m``
Hi
I’ve been fiddling a bit with ListIconGadget, and realized there doesn’t appear to be a proper implementation for PB commands to detect fully the state of a checkbox for when an item becomes checked or unchecked. And this is a problem when clicking directly on a ListIconGadget checkboxes, if I were to select a line and not try to change a line checkbox state, correct line information returns that allows me to retrieve the actual state of that line checkbox, but if there is no selection in ListIconGadget and you check or uncheck directly on a checkbox there is a problem and if there is a selection in a ListIconGadget and you check or uncheck directly a checkbox which is other-than the selected line then that is a problem in addition.
Now I could simply read every line in a ListIconGadget, and check its checkbox state but I were trying to avoid this for large list of items by making a cache of all which gets changed from the original state (for increase speed).
Posted: Sun Mar 20, 2005 3:36 am
by Sparkie
See if this helps...
Code: Select all
#LVN_ITEMCHANGED = #LVN_FIRST-1
#MyWindow = 0
#MyGadget = 1
Procedure myWindowCallback(hWnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*pnmhdr.NMHDR = lParam
Select *pnmhdr\code
Case #LVN_ITEMCHANGED
*lvChange.NMLISTVIEW = lParam
Debug *lvChange\uNewState >>12 &$FFFF
;--> Read the State image mask value ( 1 = un-checked 2 = checked
Select *lvChange\uNewState >>12 &$FFFF
Case 1
StatusBarText(0, 0, "Item " + Str(*lvChange\iItem) + " has been un-checked")
Case 2
StatusBarText(0, 0, "Item " + Str(*lvChange\iItem) + " has been checked")
EndSelect
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(#MyWindow, 100, 100, 350, 140, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "ListIcon Test") And CreateGadgetList(WindowID())
CreateStatusBar(0, WindowID())
ListIconGadget(#MyGadget, 5, 5, 340, 110, "Name", 100, #PB_ListIcon_CheckBoxes | #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#MyGadget, 1, "Address", 250)
AddGadgetItem(#MyGadget, -1, "Harry Rannit" + Chr(10) + "12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(#MyGadget, -1, "Ginger Brokeit" + Chr(10) + "130 PureBasic Road, BigTown, CodeCity")
SetWindowCallback(@myWindowCallback())
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
*Edited to fix code*
Posted: Sun Mar 20, 2005 3:51 am
by PB
> See if this helps
Your code has a bug somewhere, Sparkie... run it and do this:
(1) Click Ginger's name (not her checkbox).
(2) Click Harry's checkbox.
(3) Click Ginger's checkbox.
(4) Repeat (3) and Ginger's state doesn't change anymore...
(A native command to get the checkbox state of a ListIconGadget item would be nice).
Posted: Sun Mar 20, 2005 3:53 am
by Phant0m``
Thanks Sparkie
This is something I was looking for as an alternative code, would be nice however to see fully working PB command to retrieve checkbox state. Anyways, thanks

Posted: Sun Mar 20, 2005 3:58 am
by Sparkie

Must have left something behind in the copy/paste. I'll go back and redo for you.

Posted: Sun Mar 20, 2005 4:00 am
by Phant0m``
Posted: Sun Mar 20, 2005 4:16 am
by Sparkie
Ok, it wasn't a copy/paste issue. it was a Sparkie issue.
I've edited the code above so it should work now.
Posted: Sun Mar 20, 2005 4:20 am
by Phant0m``
Sparkie! You da man!

Posted: Sun Mar 20, 2005 4:21 am
by Sparkie
I have my moments.

Posted: Sat Mar 29, 2008 1:10 pm
by UserOfPure
Dear team, do you think it's possible for the GetGadgetState() command to return the ListIconGadget item when a checkbox is checked, like in Sparkie's example? At the moment the command only returns which item is selected, and takes no consideration if a checkbox is actioned. I think a checkbox action should override any item selection so that GetGadgetState() shows which item had its checkbox checked.
Re:
Posted: Wed Jun 19, 2013 9:49 am
by Joris
UserOfPure wrote:Dear team, do you think it's possible for the GetGadgetState() command to return the ListIconGadget item when a checkbox is checked, like in Sparkie's example? At the moment the command only returns which item is selected, and takes no consideration if a checkbox is actioned. I think a checkbox action should override any item selection so that GetGadgetState() shows which item had its checkbox checked.
+1
Thanks.
Re: ListIconGadget & checkbox states
Posted: Wed Jun 19, 2013 2:12 pm
by em_uk
Isn't this already implemented?
Code: Select all
If GetGadgetItemState(#List,1) & #PB_ListIcon_Checked
do stuff
Endif
If the above line is selected and ticked then do stuff.
Re: ListIconGadget & checkbox states
Posted: Wed Jun 19, 2013 5:20 pm
by Joris
em_uk wrote:Isn't this already implemented?
Code: Select all
If GetGadgetItemState(#List,1) & #PB_ListIcon_Checked
do stuff
Endif
If the above line is selected and ticked then do stuff.
No.
For GetGadgetItemState you need the item index to know from which item you wont the state, and that isn't 'send' when the check is placed.
(with api's this is possible...)