ListIcons: color of selected row, can be set?
ListIcons: color of selected row, can be set?
Hello:
can the color of the selected row of a listicons (by SetGadgetState(), not by mouse) be set other than the default one?
The color is too fade
using W10, PB6.10b2
Thanks
can the color of the selected row of a listicons (by SetGadgetState(), not by mouse) be set other than the default one?
The color is too fade
using W10, PB6.10b2
Thanks
PureBasic: Surprisingly simple, diabolically powerful
Re: ListIcons: color of selected row, can be set?
Maybe Infratec's sample will help...

Code: Select all
;==================================================================
;
; Author: Infratec
; Date: September 22, 2017
;
; Question:
; The code below shows the centre item is slightly coloured.
; Is there any way to get it to be the same as when selected by the mouse, i.e. Dark Blue background?
;==================================================================
If OpenWindow(0, 100, 100, 300, 200, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 290, 120, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "Address", 250)
AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
SetActiveGadget(0) ; this is required to change the color... comment out to see.
SetGadgetItemState(0,1,#PB_ListIcon_Selected)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
- It was too lonely at the top.
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Re: ListIcons: color of selected row, can be set?
Blueb, I think morosh means to give selected lines a different colour than Windows normally uses, not just select them.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: ListIcons: color of selected row, can be set?
You may try this 16 year old example from Sparkie. I have just tested it successfully on Windows 7 with PB 5.73 x86 and x64. Unfortunately I am on vacation with a 14 year old iMac and a BootCamp version which only supports Windows 7...morosh wrote:can the color of the selected row of a listicons (by SetGadgetState(), not by mouse) be set other than the default one?

Re: ListIcons: color of selected row, can be set?
Thank you all!!!
Finally SetGadgetItemColor did the job simply
just an extract
Finally SetGadgetItemColor did the job simply
Code: Select all
Procedure highlight2()
Define str.s
Static xx.u
str=":"+LCase(GetGadgetText(52))
SetGadgetItemColor(102,xx-1,#PB_Gadget_BackColor,$ffffff) ; reset color
For i=1 To CountGadgetItems(102)
; Debug i
If FindString(GetGadgetItemText(102,i-1),str)
Debug "Match"
SetGadgetItemColor(102,i-1,#PB_Gadget_BackColor,$cc33ff) ; set new color
; SetGadgetAttribute(102,i-1)
xx=i
Break
EndIf
Next
EndProcedure
PureBasic: Surprisingly simple, diabolically powerful
Re: ListIcons: color of selected row, can be set?
I need to DisableGadget(GadgetName, #True) the ListIconGadget while my app updates other data to keep users from clicking on other items in the list. The SetGadgetItemColor does not seem to work when I DisableGadget(GadgetName, #False) the ListIconGadget.
Before the ListIconGadget is disable the selected row is highlighted in blue. When you disable and re-enable it the blue is gone and the row is just in a light grey.
Have tried multiple Gadget Get/Set options. Any help would be appreciated.
Before the ListIconGadget is disable the selected row is highlighted in blue. When you disable and re-enable it the blue is gone and the row is just in a light grey.
Have tried multiple Gadget Get/Set options. Any help would be appreciated.
Re: ListIcons: color of selected row, can be set?
digital32 wrote: Tue Oct 08, 2024 10:34 pm Have tried multiple Gadget Get/Set options. Any help would be appreciated.
Code: Select all
SetActiveGadget(0) ; this is required to change the color... comment out to see.
No focus : background color of the line is grey. With focus, background color is blue.
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Except on this sentence...
Re: ListIcons: color of selected row, can be set?
Tried that. Here is the code. Did not set the row back to blue. Still a grey.
DisableGadget(ListIcon_Machine_List,#False) ; Allow Clicking on new row after data is loaded.
SetActiveGadget(ListIcon_Machine_List)
SetGadgetItemColor(ListIcon_Machine_List, GetGadgetState(ListIcon_Machine_List), #PB_Gadget_BackColor, $FFFF00)
DisableGadget(ListIcon_Machine_List,#False) ; Allow Clicking on new row after data is loaded.
SetActiveGadget(ListIcon_Machine_List)
SetGadgetItemColor(ListIcon_Machine_List, GetGadgetState(ListIcon_Machine_List), #PB_Gadget_BackColor, $FFFF00)
Re: ListIcons: color of selected row, can be set?
Are you really sure your list has a selected item? (GetGadgetState(ListIcon_Machine_List)>=0)
Code: Select all
If OpenWindow(0, 100, 100, 400, 230, "ListIconGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 390, 90, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "Address", 250)
AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
ListIconGadget(1, 5, 100, 390, 90, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(1, 1, "Address", 250)
AddGadgetItem(1, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(1, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
ButtonGadget(2, 5, 200, 80, 22, "Disable")
ButtonGadget(3, 90, 200, 80, 22, "Enable")
SetGadgetState(0, 0)
SetGadgetState(1, 0)
SetActiveGadget(1)
Repeat
Evenment = WaitWindowEvent()
Select Evenment
Case #PB_Event_Gadget
Select EventGadget()
Case 2:DisableGadget(0, #True)
Case 3:DisableGadget(0, #False):SetActiveGadget(0)
EndSelect
EndSelect
Until Evenment = #PB_Event_CloseWindow
EndIf
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Except on this sentence...
Re: ListIcons: color of selected row, can be set?
If I comment out the DisableGadget parts it works fine. Selection stays highlighted.