[SOLVED] (end)User Friendly Way to delete ListIconGadget line?
Posted: Thu Oct 16, 2025 4:50 am
I have a populated listIconGadget() Where I would like to allow the user to select a line and press Delete to remove that line. Is there any way to do that without a callback? (What a Pain!) We can use the following for sample purposes:
I figured out one way using combo of #WM_KEYDOWN and GetKeyState_(#VK_DELETE) as illustrated in the revised code above.
Code: Select all
If OpenWindow(0, 100, 100, 300, 220, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 290, 200, "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, "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, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
Repeat
Select WaitWindowEvent()
Case #WM_KEYDOWN
Debug "KEY down"
If GetKeyState_(#VK_DELETE)
Debug "Yep!!!"
h.i = CountGadgetItems(0)
Debug h
If h > 3
h = h-1
For e.i = h To 0 Step -1
If GetGadgetItemState(0, e)
RemoveGadgetItem(0, e)
EndIf
Next e
EndIf
EndIf
EndSelect
Until Event = #PB_Event_CloseWindow