GetIndex()
is a method of event
, so you should be using event:GetIndex()
, but I don't think it's populated for mouse events (LEFT_CLICK). For mouse events you may need to use wxListCtrl:FindItem (if it's available through wxlua) to get the item closest to the position of the click. To get the coordinates of the click you can use event:GetPoint()
(if available) or something like this:
local mousePos = wx.wxGetMousePosition() -- mouse pos on screen
local clientPos = lpanelList:ScreenToClient(mousePos)
Instead of using mouse events, you can also use wxEVT_COMMAND_LIST_ITEM_ACTIVATED
, in which case you can do local index = event:GetIndex()
(I think this index is 0-based).
If you are using wxlua, I found the samples that are included with it (samples/
folder) a good source of solutions supported with wxlua API.