Listicongadget/RowSelect

Just starting out? Need help? Post your questions and find answers here.
GenRabbit
Enthusiast
Enthusiast
Posts: 151
Joined: Wed Dec 31, 2014 5:41 pm

Listicongadget/RowSelect

Post by GenRabbit »

Hi
is there a better way to detect row selected in listicongadget than this?

Code: Select all

	tv2 = CountGadgetItems(#ListIconGadget1)
	tv1 = 0
	While tv1 < tv2
		If GetGadgetItemState(#ListIconGadget1, tv1) & #PB_ListIcon_Selected
			Debug tv1
			Break
		EndIf
		tv1 +1	
	Wend	
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Listicongadget/RowSelect

Post by Kiffi »

Code: Select all

Debug GetGadgetState(#ListIconGadget1)
Hygge
GenRabbit
Enthusiast
Enthusiast
Posts: 151
Joined: Wed Dec 31, 2014 5:41 pm

Re: Listicongadget/RowSelect

Post by GenRabbit »

Thanks. That shortened it a lot. :)
jak64
Enthusiast
Enthusiast
Posts: 619
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

Re: Listicongadget/RowSelect

Post by jak64 »

Hello Kiffi,
I tested Debug GetGadgetState(#ListIconGadget1).

It returns -1 but not the number of the corresponding line of the ListIconGadget.

How to know the line of which only the checkbox has been checked?

Thank you
tua
User
User
Posts: 68
Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada

Re: Listicongadget/RowSelect

Post by tua »

From the help:

- GetGadgetState(): Returns the first selected item or -1 if there is no item selected.

Looks like you didn't select (= click on) an item...
tua
User
User
Posts: 68
Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada

Re: Listicongadget/RowSelect

Post by tua »

As for your checkbox question:

Code: Select all

If OpenWindow(0, 100, 100, 300, 200, "Checkbox in ListIconGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 10, 10, 280, 150, "Item", 250, #PB_ListIcon_CheckBoxes)
  AddGadgetItem(0, -1, "Item 1")
  AddGadgetItem(0, -1, "Item 2")
  AddGadgetItem(0, -1, "Item 3")
  
  ButtonGadget(1, 10, 170, 100, 20, "Check State")
  Repeat
    Event = WaitWindowEvent()
    Select Event
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1 ; ButtonGadget clicked
            For i = 0 To CountGadgetItems(0) - 1
              If GetGadgetItemState(0, i) & #PB_ListIcon_Checked
                Debug "Item " + Str(i + 1) + " is checked"
              EndIf
             Next
        EndSelect
    EndSelect
  Until Event = #PB_Event_CloseWindow
EndIf
jak64
Enthusiast
Enthusiast
Posts: 619
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

Re: Listicongadget/RowSelect

Post by jak64 »

hello tua,
Thanks for the code
Post Reply