Page 1 of 1

Issue with SetGadgetState() and SetGadgetItemState() on Windows

Posted: Fri Dec 19, 2025 3:20 am
by bal
Seems there is an issue with both SetGadgetState() and SetGadgetItemState() on Windows when using them on ListViewGadget, ListIconGadget and TreeGadget.
Linux looks to be fine, but could not test this on Mac or RPi.

ListViewGadget

Code: Select all

#win = 0
#ListView = 0
If OpenWindow(#win, 0, 0, 320, 140, "ListViewGadget SetGadgetState / SetGadgetItemState", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListViewGadget(#ListView, 10, 10, 300, 120)
  For a = 0 To 9
    AddGadgetItem (#ListView, -1, "Item " + Str(a) + " of the ListView")
  Next
  
  ; *** SetGadgetState() ***
  ; Works okay on Windows
  ; Works okay on Linux GTK2
  ; Works okay on Linux GTK3
  ; Works okay on Linux Qt
  SetGadgetState(#ListView, 1)
  
  ; *** SetGadgetItemState() ***
  ; Doesn't do anything on Windows
  ; Works okay on Linux GTK2
  ; Works okay on Linux GTK3
  ; Works okay on Linux Qt
  ;SetGadgetItemState(#ListView, 2, #True)
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
ListIconGadget

Code: Select all

#win = 0
#ListIcon = 0
If OpenWindow(#win, 0, 0, 320, 140, "ListIconGadget SetGadgetState / SetGadgetItemState", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(#ListIcon, 10, 10, 300, 120, "Column-0", 200)  ;, #PB_ListIcon_AlwaysShowSelection)  ; this flag doens't make any difference
  For a = 0 To 9
    AddGadgetItem (#ListIcon, -1, "Item " + Str(a) + " of the ListIcon")
  Next
  
  ; *** SetGadgetState() ***
  ; Doesn't do anything on Windows
  ; Works okay on Linux GTK2
  ; Works okay on Linux GTK3
  ; Works okay on Linux Qt
  SetGadgetState(#ListIcon, 1)
  
  ; *** SetGadgetItemState() ***
  ; Doesn't do anything on Windows
  ; Works okay on Linux GTK2
  ; Works okay on Linux GTK3
  ; Works okay on Linux Qt
  ;SetGadgetItemState(#ListIcon, 2, #PB_ListIcon_Selected)
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
TreeGadget

Code: Select all

#win = 0
#Tree = 0
If OpenWindow(#win, 0, 0, 320, 140, "TreeGadget SetGadgetState / SetGadgetItemState", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  TreeGadget(#Tree, 10, 10, 300, 120)  ; , #PB_Tree_AlwaysShowSelection)  ; this flag doens't make any difference
  For a = 0 To 9
    AddGadgetItem (#Tree, -1, "Item " + Str(a) + " of the Tree")
  Next
  
  ; *** SetGadgetState() ***
  ; Doesn't do anything on Windows
  ; Works okay on Linux GTK2
  ; Works okay on Linux GTK3
  ; Works okay on Linux Qt
  SetGadgetState(#Tree, 1)
  
  ; *** SetGadgetItemState() ***
  ; Doesn't do anything on Windows
  ; Works okay on Linux GTK2
  ; Works okay on Linux GTK3
  ; Works okay on Linux Qt
  ;SetGadgetItemState(#Tree, 2, #PB_Tree_Selected)
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: Issue with SetGadgetState() and SetGadgetItemState() on Windows

Posted: Fri Dec 19, 2025 1:58 pm
by Fred
Seems to work as expected here, can anybody else confirm ?

Re: Issue with SetGadgetState() and SetGadgetItemState() on Windows

Posted: Fri Dec 19, 2025 4:21 pm
by Axolotl
I'm not sure if the behavior is as described in the help section.
I tested the first two examples ListViewGadget() and ListIconGadget() with PB 630 b6.
In all of these cases (see below), the commands did not select any entries.

Code: Select all

  ; The examples from above and acc. to help text for SetGadgetState() and SetGadgetItemState() 
  ; Doesn't do anything on Windows
  SetGadgetItemState(#ListView, 2, #True)   ; <= no selection on ListView ! 

  ; Doesn't do anything on Windows
  SetGadgetState(#ListIcon, 1)  ; <= selection shown with SetActiveGadget(#ListIcon) 

  ; Doesn't do anything on Windows
  SetGadgetItemState(#ListIcon, 2, #PB_ListIcon_Selected)  ; <= selection with Activate..
  ; BUT: this works with flag: #PB_ListIcon_AlwaysShowSelection 


=> It looks to me, that the inconsistency is on ListViewGadget and SetGadgetItemState()

Re: Issue with SetGadgetState() and SetGadgetItemState() on Windows

Posted: Fri Dec 19, 2025 4:29 pm
by Little John
I can confirm all problems reported above by bal, tested with PB 6.30 beta 5 (x64) on Windows 11.

Re: Issue with SetGadgetState() and SetGadgetItemState() on Windows

Posted: Fri Dec 19, 2025 5:36 pm
by bal
Hey guys, thanks for looking into this.

Seems this has been broken for a long time. Just went back to 4.61 on Windows and I can reproduce the same issue.
I created most of my GUI apps on Linux, that's why I've never noticed this bug.