ListIconGadget - detect a click on the header?
Posted: Sun Jan 01, 2023 8:52 pm
I'm fooling around a bit with the ListIconGadget, and I was wondering if there is a way to separate clicks on the top (header) and the first row.
I'm studying the callback based approaches (viewtopic.php?t=80375) but I was wondering if it could be done without a callback.
For now, I use this to detect the cell that was clicked upon:
This works perfectly, however
I was thinking about (ab)using this for a header click. The idea was to use a click on the header to sort the column, but... if I abuse
the event returned by PB's WaitWindowEvent(), I can't find a way to discern between a click on the header and on the first cell.
(A propos, is there a way to find the clicked cell without relying on WinApi?)
Now, abusing the event mechanism a bit this is what I'm trying to accomplish: a click on a header should trigger a menu event. (In that menu event I do some sorting etc.) The best I could come up with is:
In more simple words, is there a way to detect a click on the header of a ListIconGadget? (Preferably without callbacks.)
I'm studying the callback based approaches (viewtopic.php?t=80375) but I was wondering if it could be done without a callback.
For now, I use this to detect the cell that was clicked upon:
Code: Select all
Procedure.i x_getlisticonselected(gadget_nr.i,window_nr.i = 0) ; find selected cell in a listicongadget
Protected gx.i, gy.i, pinfo.LVHITTESTINFO
; global x_retval.i, x_retval_x.i, x_retval_y.i
;
; *** find the cell in a listicongadget under the mouse
;
; in: gadget_nr.i - pb listicongadget nr
; window_nr.i - pb window number
;
; retval: n
;
; out: x_retval.i - row
; x_retval_x.i - column
; x_retval_y.i - row
;
gx = GadgetX(gadget_nr)
gy = GadgetY(gadget_nr)
pinfo\pt\x = WindowMouseX(window_nr)-gx
pinfo\pt\y = WindowMouseY(window_nr)-gy
SendMessage_(GadgetID(gadget_nr),#LVM_SUBITEMHITTEST,0,@pinfo)
;
x_retval_x = pInfo\iSubItem
x_retval_y = pInfo\iItem
x_retval = x_retval_y
;
ProcedureReturn x_retval
EndProcedure


(A propos, is there a way to find the clicked cell without relying on WinApi?)
Now, abusing the event mechanism a bit this is what I'm trying to accomplish: a click on a header should trigger a menu event. (In that menu event I do some sorting etc.) The best I could come up with is:
Code: Select all
event = WaitWindowEvent()
If event = 514
;
x_getlisticonselected(#g_filelist_nr,#w_main_nr)
If x_retval_x >= 0 And x_retval_y = 0
column = x_retval_x
event = #PB_Event_Menu
event_menu = #menu_filelist_sort
EndIf
EndIf