Check if listbox row has content?

Hi,
when my user contextual-clicks over a listbox, I need to determine if the listbox row under the mouse is empty or not, before I can proceed.
I know how to check if a row is selected, but am not sure how to check if an unclicked row has content?

Can anyone advise me?

Thank you all in advance

First check to see if there is a row underneath the cell
If me.listIndex + 1 = Listcount then return //The user has clicked on the last row There may be a boolean to return?

If me.Cell(me.ListIndex + 1, 0) = “” then //no content in the Cell(x, 0) of the next row

Your ConstructContextualMenu event will pass the X and Y coordinates of the mouse. Using those in RowFromXY will get you the row the mouse was right-clicked in. If that is -1, the mouse was not in an actual row (somewhere else in the llistbox). You can then use the Listbox.Cell function to get the cell contents, if any, or loop through the columns in that row to check the entire row. Something like:

[code]Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean

if me.ListCount > 0 then
if me.rowfromxy(x,y) = -1 return false // we’re not in a real row
// Build your contextual menu
base.Append( new MenuItem( "Contextual click in row " ))
return true
end if
return false
End Function[/code]

RowFromXY is the solution.
Unfortunately under Cocoa if you showed a popupmenu after even if you do not want to make it appear then you will show in any case the last one

<https://xojo.com/issue/32674>

Thanks guys.
I can’t believe something as standard as the contextual click problem is ranked 435th!

There is a workaround using the mouse down event, but then a right click does not select the listbox row below it.
Ranked at 435, it doesn’t even look like it is going to get fixed any time soon :frowning:

It’s a bit like driving a vehicle which does not have working indicators. The vehicle still works, and you can always stick your arm out the window - but is extremely annoying, looks terrible, and causes people to buy an alternative vehicle.

Now I’m starting to sound like a whiney developer :frowning:

[quote=135161:@Richard Summers]There is a workaround using the mouse down event, but then a right click does not select the listbox row below it.
Ranked at 435, it doesn’t even look like it is going to get fixed any time soon :([/quote]
Ranking doesn’t necessarily mean much. The fact that it has a rank at all is good. Don’t despair!

Workaround has been discussed recently here https://forum.xojo.com/15629-contextualmenu-always-displays-last-items