ContextualMenuAction wrong Row # ?

Hi all,

the code works fine excepted on the part that returns the Row #. The Row # is the one below the “released" (MouseUp) location: if you have a 10 items long COntextualMenu, and click in Row 0 / release teh Mouse on the 10th item, the Text will fall - say - on Row 10 (or so), not on the clicked Row !

If I use the arrow key to choose the entry from the ContextualMenu, the filled Cell will be the clicked Row. (What I expect).

Idea ?


ContextualMenuAction Event:

[code] //
// ContextualMenuAction: put the Contextual selected text into the Cell below the click
Dim ClickRow As Integer
Dim ClickColumn As Integer

// Get the clicked Cell location
ClickRow = Me.RowFromXY( System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top)
ClickColumn = Me.ColumnFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top)

If hitItem <> Nil Then
// Put the selected Name in the selected Cell…
Me.Cell(ClickRow, ClickColumn) = hitItem.Text
End If

// Handled !
Return True[/code]

PS: ConstructContextualMenu is not involved here (it just set three items in the ContextualMenu).

Edit: the Listbox (0,0) is set at 20,60 (window); in case it matters.

I need to store x and y in ConstructContextualMenu and use these values in ContextualMenu.

Your ClickRow and ClickColumn values are holding the position of the click on the menu item, not of the right lick on the listbox which then shows the menu.

Thanks Eli: your description seems accurate.

So, I will add two window Properties and I will fill them in ConstructContextualMenu.

BTW: I just learned there is a contextual menu key on the keyboard. Since early 1980, I never saw it :wink:
(is this the ctrl key ?)

PS: I also am asking myself how in some previous (the one I checked to add this feature here) project(s) I do not fall into that trap…

No, it is next to the control key.

Not a clue. It should have behaved the same.

Thanks Tim.

fn ? (if so, it is on Windows and I do not realized that… I simply use it)

So I certainly use it differently (I will take a moment to check how I use it).

BTW: you are right ! I use it for Columns, not Row !
(only column is relevant in that other project !)

fn is on the left, contextual menu is on the right.

Suggestion implemented: works fine.