Hi,
is there an easy way to disable a ListIconGadget, but keep it interactable? Like a readonly EditorGadget, no changes can be made, but it's scrollable. I want the ListIcon to be scrollable, but no changes made to the selected elements.
I know how to do this via subclassing on Windows, but maybe there's an easier way.
Disable ListIcon, but keep it interactable
Disable ListIcon, but keep it interactable
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/2*DX517, 164TB+82TB+28TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/2*DX517, 164TB+82TB+28TB+2TB SSD
Re: Disable ListIcon, but keep it interactable
Hi
Workaround
Workaround
Code: Select all
If OpenWindow(0, 0, 0, 800, 600, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
lic1 = ListIconGadget(#PB_Any, 10, 10, 780, 540, "Name", 150, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
lic2 = ListIconGadget(#PB_Any, 0, 0, 0, 0, "Name", 150, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(lic1, 1, "Address", 350)
For i = 0 To 100
AddGadgetItem(lic1, -1, Str(i)+" Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
Next
ButtonGadget(0,10,560,120,24,"Disable")
ButtonGadget(1,140,560,120,24,"Remove")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 0
disflag ! 1
Debug disflag
If disflag = 1
Swap lic1,lic2
SetGadgetText(0,"Enable")
SetGadgetColor(lic2,#PB_Gadget_BackColor,$D6D6D6)
Else
Swap lic1,lic2
SetGadgetText(0,"Disable")
SetGadgetColor(lic1,#PB_Gadget_BackColor,#PB_Default)
EndIf
Case 1
RemoveGadgetItem(lic1,2)
EndSelect
EndSelect
Until Quit = 1
EndIf
Egypt my love
- Michael Vogel
- Addict

- Posts: 2839
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Disable ListIcon, but keep it interactable
No idea what is needed as listicons can only be edited by writing code for it, so here you have to check if it is allowed or not...
Using Rashad's code to demonstrate the shortcut 'R' won't work when the listicon gadget gets 'disabled':
Using Rashad's code to demonstrate the shortcut 'R' won't work when the listicon gadget gets 'disabled':
Code: Select all
OpenWindow(0, 0, 0, 800, 600, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0,10,560,120,24,"Disable")
ButtonGadget(1,140,560,120,24,"Remove")
txt1= TextGadget(#PB_Any,10,10,200,25,"Your List:")
lic1= ListIconGadget(#PB_Any, 10, 40, 780, 500, "Name", 150, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(lic1, 1, "Address", 350)
For i = 0 To 100
AddGadgetItem(lic1, -1, Str(i)+" Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
Next
AddKeyboardShortcut(0,#PB_Shortcut_D,0)
AddKeyboardShortcut(0,#PB_Shortcut_R,1)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget,#PB_Event_Menu
Select EventGadget()
Case 0
disflag ! 1
If disflag = 1
SetGadgetText(0,"Enable")
Else
SetGadgetText(0,"Disable")
EndIf
SetGadgetText(txt1,"Your List"+StringField(":. (locked):",disflag+1,"."))
DisableGadget(1,disflag)
Case 1
If disflag=0
RemoveGadgetItem(lic1,2)
Else
Debug "Locked"
EndIf
EndSelect
EndSelect
Until Quit