Setting and Getting GadgetITemData on a ListIconGadget

Just starting out? Need help? Post your questions and find answers here.
User avatar
tikidays
User
User
Posts: 46
Joined: Tue Oct 24, 2023 6:47 am
Location: New Zealand
Contact:

Setting and Getting GadgetITemData on a ListIconGadget

Post by tikidays »

Hi, SETGADGETITEMDATA and GETGADGETITEMDATA dont appear to work with ListIconGadget, see example below, why is this not working? I've tried this with 6.03 LTS Windows 11 and 6.10 LTS - C Backend (MacOS X - arm64), the manual says it should support this.

Code: Select all

; Shows possible flags of ListIconGadget in action...
  If OpenWindow(0, 0, 0, 700, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ; left column
    TextGadget    (6,  10,  10, 330, 20, "ListIcon Standard", #PB_Text_Center)
    ListIconGadget(0,  10,  25, 330, 70, "Column 1", 100)
    TextGadget    (7,  10, 105, 330, 20, "ListIcon with Checkbox", #PB_Text_Center)
    ListIconGadget(1,  10, 120, 330, 70, "Column 1", 100, #PB_ListIcon_CheckBoxes)  ; ListIcon with checkbox
    TextGadget    (8,  10, 200, 330, 20, "ListIcon with Multi-Selection", #PB_Text_Center)
    ListIconGadget(2,  10, 215, 330, 70, "Column 1", 100, #PB_ListIcon_MultiSelect) ; ListIcon with multi-selection
    ; right column
    TextGadget    (9, 360,  10, 330, 20, "ListIcon with separator lines",#PB_Text_Center)
    ListIconGadget(3, 360,  25, 330, 70, "Column 1", 100, #PB_ListIcon_GridLines)
    TextGadget   (10, 360, 105, 330, 20, "ListIcon with FullRowSelect and AlwaysShowSelection",#PB_Text_Center)
    ListIconGadget(4, 360, 120, 330, 70, "Column 1", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
    TextGadget   (11, 360, 200, 330, 20, "ListIcon Standard with large icons",#PB_Text_Center)
    ListIconGadget(5, 360, 220, 330, 65, "", 200,#PB_ListIcon_GridLines)
    For a = 0 To 4            ; add columns to each of the first 5 listicons
      For b = 2 To 4          ; add 3 more columns to each listicon
        AddGadgetColumn(a, b, "Column " + Str(b), 65)
      Next
      For b = 0 To 2          ; add 4 items to each line of the listicons
        AddGadgetItem(a, b, "Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4")
      Next
    Next
   
    ; Here we change the ListIcon display to large icons and show an image
    If LoadImage(0, #PB_Compiler_Home+"examples/sources/Data/File.bmp")     ; change path/filename to your own 32x32 pixel image
      SetGadgetAttribute(5, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
      AddGadgetItem(5, 1, "Picture 1", ImageID(0))
      AddGadgetItem(5, 2, "Picture 2", ImageID(0))
      SetGadgetItemData(5,2,1234)  ; <<<< Setting to 1234
    EndIf
    
    Debug GetGadgetItemData(5,2) ; <<<< Why is this zero?
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Setting and Getting GadgetITemData on a ListIconGadget

Post by HeX0R »

There is no item at index 2, therefore nothing will be set!
AddGadgetItem(5, 1, "Picture 1", ImageID(0)) on an empty List will NOT add it to position 1, but to position 0
infratec
Always Here
Always Here
Posts: 7587
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Setting and Getting GadgetITemData on a ListIconGadget

Post by infratec »

What HeXOR mean:

Code: Select all

If LoadImage(0, #PB_Compiler_Home+"examples/sources/Data/File.bmp")     ; change path/filename to your own 32x32 pixel image
      SetGadgetAttribute(5, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
      AddGadgetItem(5, 0, "Picture 1", ImageID(0))
      AddGadgetItem(5, 1, "Picture 2", ImageID(0))
      SetGadgetItemData(5,1,1234)  ; <<<< Setting to 1234
    EndIf
    
    Debug GetGadgetItemData(5,1)
User avatar
tikidays
User
User
Posts: 46
Joined: Tue Oct 24, 2023 6:47 am
Location: New Zealand
Contact:

Re: Setting and Getting GadgetITemData on a ListIconGadget

Post by tikidays »

Odd This was copied as is from the Help example, I only added the SET and GET... so it has incorrectly got 1 and 2 instead of 0 and 1?
infratec
Always Here
Always Here
Posts: 7587
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Setting and Getting GadgetITemData on a ListIconGadget

Post by infratec »

User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Setting and Getting GadgetITemData on a ListIconGadget

Post by charvista »

We all have nine fingers. The first one is the zeroth one. :o
At school, we learned to count from one, not from zero.... hence the confusion. :mrgreen:
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
BarryG
Addict
Addict
Posts: 4130
Joined: Thu Apr 18, 2019 8:17 am

Re: Setting and Getting GadgetITemData on a ListIconGadget

Post by BarryG »

charvista wrote: Sun Apr 14, 2024 1:12 pmAt school, we learned to count from one, not from zero
Reminds me of this -> https://youtu.be/76J3mHnHHOE?si=loTImLs-VuU0YJeE&t=89 :mrgreen:
User avatar
mk-soft
Always Here
Always Here
Posts: 6209
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Setting and Getting GadgetITemData on a ListIconGadget

Post by mk-soft »

I have 11 fingers ...

left side. 10, 9, 8, 7, 6 and right side 5, together 11 8)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply