GetAttribute() always returns 0 - bug?

Just starting out? Need help? Post your questions and find answers here.
tua
User
User
Posts: 68
Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada

GetAttribute() always returns 0 - bug?

Post by tua »

Code: Select all

Procedure GridLeftClick()
  ; always returns 0 no matter on which column one clicks...
  Debug "Row: " + Str(GetGadgetState(22)) + #CRLF$ + "Col: " + GetGadgetAttribute(22, #PB_ListIcon_ClickedColumn) + #CRLF$ + "Cols: " +  GetGadgetAttribute(22, #PB_ListIcon_ColumnCount) 
EndProcedure

Procedure Demo()
  If OpenWindow(17, 100, 100, 400, 300, "ListIconGadget Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
      ListIconGadget(22, 10, 10, 380, 250, "Column 1", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_GridLines)
      AddGadgetColumn(22, 1, "Column 2", 100)
      AddGadgetColumn(22, 2, "Column 3", 100)
      ; Add some items
      For i = 0 To 9
        AddGadgetItem(22, -1, "Item " + Str(i) + Chr(10) + "Value " + Str(i) + Chr(10) + "Data " + Str(i))
      Next
      BindGadgetEvent(22, @GridLeftClick(),  #PB_EventType_LeftClick)
  EndIf      
EndProcedure

Demo()

Repeat 
  Event = WaitWindowEvent() 
Until Event = #PB_Event_CloseWindow  
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: GetAttribute() always returns 0 - bug?

Post by Fred »

You need to bind on '#PB_EventType_ColumnClick' and not '#PB_EventType_LeftClick'
tua
User
User
Posts: 68
Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada

Re: GetAttribute() always returns 0 - bug?

Post by tua »

Since this seems to pertain to column header clicks only, can I infer from your answer that there is no 'native' PB way of obtaining information on which column in which row I clicked (short of having to abandon platform independency and resorting to Win API calls)?
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: GetAttribute() always returns 0 - bug?

Post by Fred »

True, there is no such info natively supported.
Post Reply