Issue with SetGadgetState() and SetGadgetItemState() on Windows

Post bugreports for the Windows version here
bal
User
User
Posts: 10
Joined: Fri Sep 03, 2010 6:15 pm

Issue with SetGadgetState() and SetGadgetItemState() on Windows

Post 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
Fred
Administrator
Administrator
Posts: 18409
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

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

Post by Fred »

Seems to work as expected here, can anybody else confirm ?
Axolotl
Addict
Addict
Posts: 902
Joined: Wed Dec 31, 2008 3:36 pm

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

Post 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()
Last edited by Axolotl on Fri Dec 19, 2025 4:35 pm, edited 1 time in total.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Little John
Addict
Addict
Posts: 4813
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

I can confirm all problems reported above by bal, tested with PB 6.30 beta 5 (x64) on Windows 11.
bal
User
User
Posts: 10
Joined: Fri Sep 03, 2010 6:15 pm

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

Post 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.
Post Reply