Determining which cell was double-clicked

The code below (From ListBox / LR) crash at the column = line:

Dim row,column as Integer row=Me.RowFromXY(System.MouseX - Me.Left - Self.Left - me.TrueWindow.Left, System.MouseY - Me.Top - Self.Top -me.TrueWindow.Top) column=Me.ColumnFromXY(System.MouseX - Me.Left - Me.Parent.Left - me.TrueWindow.Left, System.MouseY - Me.Top - Me.Parent.Top - me.TrueWindow.Top)

NilObjectException.

The code is in the DoubleClick Event.

I added 16 Rows to the ListBox using Copy in TextEdit (so a 16 lines / 4 Columns text) and Paste in the ListBox. All the copied text is correctly filled (Rows and Columns appears where expected.

I clicked in Row 0, 5.
I clicked in Column 1, 2, 3 (on a 4 Columns ListBox).

The Debugger says:

[code] Globals
column 0
Exception NilObjectException
me ListBox
row -1
self wMain.wMain

[/code]
Xojo holds 179.8MB (Activity Monitor), 140.6MB after a reboot.

After one reboot, the crash is still here.

OS X 10.10.5pb
Xojo 2015r1

You have altered the code you copied from the LR. The line calculating column contains references to Me.Parent (which is Nil) and Me.TrueWindow.

You can do it more easily. Just have a couple of properties save the column and row of the last click. That’s also the cell which was double clicked, cause when you double click, you do not move the mouse.

Thanks for your answers.

No, I do not.

and the line that is meant to get the Row # also use Me.TrueWindow.

BTW: I noticed that in .Parent and .TrueWindow, me is using lowercase vs TitledCase in the other references.

And to be sure, I copy / paste the code after the reboot, and pasted it here after it crashed.

Me.Parent, when called from a Control (a ListBox here) is meant to return a reference to the holding window (in this case).
Me.TrueWindow:

Returns a reference to the actual enclosing Window

Ashot: will do that if far away from hope.
Eli: can you share the “non altered code” ?

Yes, you copied the code for a double click in a listbox which is placed on a container control. Since Me.Parent is throwing a NilObjectException, your listbox is not placed on a container control but directly in the window. The first example in the LR is for that, you chose the second, which is for a listbox on a container control.

Try this modified listbox:
https://dl.dropboxusercontent.com/u/10747116/RealStudioClasses/ListBoxWithDoubleClick.rbo.zip

Thank you Simon.

No. I take the code from the docs and put it in the ListBox that is actually the only control of the window.

This used to works times ago.

PS: I do not tell who is throwing a NilObjectException, I only say what I get…

AND the winner is Eli: I do not noticed this morning that there were two “similar” lines in the screen. My (old) eyes where probably still sleeping :(.

Thanks all.

Yes Eli, that was it.

So much time lost because a simple (vision / MouseTargetCopy) error !