ListIcon improvement

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
tua
User
User
Posts: 68
Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada

ListIcon improvement

Post by tua »

Consider adding a method of obtaining the row & column for a cell being clicked on in a platform independent, "native" PB manner.

Currently only the selected/active row is accessible, and for the column there is no way of getting the information, short of resorting to Win API calls on Windows etc. since the column click event is reserved for column headers only.
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: ListIcon improvement

Post by Shardik »

Unfortunately #PB_ListIcon_ClickedColumn works only to detect the clicked column of a header click after #PB_EventType_ColumnClick:

Code: Select all

OpenWindow(0, 200, 100, 450, 130, "ListIcon Example")
ListIconGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20,
  "Name", 110, #PB_ListIcon_GridLines)
AddGadgetColumn(0, 1, "Address", 310)
AddGadgetItem(0, -1, "Harry Rannit" + #LF$ +
  "12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit" + #LF$ +
  "130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(0, -1, "Didi Findit" + #LF$ +
  "321 Logo Drive, Mouse House, Downtown")

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      If EventGadget() = 0
        If EventType() = #PB_EventType_ColumnClick
          Debug "Left click on header of column " +
            GetGadgetAttribute(0, #PB_ListIcon_ClickedColumn)
        EndIf
      EndIf
  EndSelect
ForEver

Therefore you may try out this cross-platform example which displays the row and column of a clicked cell in a ListIconGadget.

It would be nice if the team could implement that code natively in PureBasic... :wink:
Post Reply