ListBox row click selects wrong row

So, i created a new thread.

If i press on row 0 i cannot even select it, if i press on row 1 it selects me row 0

I made a small movie showing the result, i dont know if its related or not .

Movie here

It seems that after more digging this issue gets created after i put the listbox into a window and the window has some custom code in it it takes as well the formatting of the window related to the selection color and so, ill try to make a sample project and if still shows there ill put it here and even open a feedback case to see if it`s ListBox related or some other issues.

Thanks again.

A project showing the issue would be helpful as it is likely some coding problem.

im doing that now, the project is based on SamNSPopover so im doing now tests to see if there is the problem, once i discover the issue i`ll post it here with the sample project.

Thanks

Here is a project demo that has the issue . I`m guessing as well that is something related to the NSPopup inheritance as i see that it overrides the select color and as well this select issue.

Thanks .

I saw the problem in both the current Xojo and Xojo 2013 R3.

Actually it is not exactly a row difference as when you click in about the bottom 15% of a row that row gets selected.

Moving the Listbox up or down has no effect on the problem, or in other words displays the same problem.

Changing the default row height of the listbox however does have an effect (try setting it to 30, then about 50% of the row selects the right row) though the problem is still there.

Checkboxes or Radiobuttons on the Popup don’t show that behaviour.

Wether Listbox has heading or not makes no difference.

Seems to be a problem with the Listbox

[quote=246522:@Markus Winter]Checkboxes or Radiobuttons on the Popup don’t show that behaviour.

Wether Listbox has heading or not makes no difference.

Seems to be a problem with the Listbox[/quote]

Well indeed but it seems that it is related to that NSPopover part , as if you take a listbox and put it on a window it works ok, when you have it in that setup does not work. More digging, hope that i`ll find the issue soon.

Thanks .

I have no issues with the row selection of a plain listbox in R2015 4.1.
The posted project doesn’t work correctly with R20154.0 too.

Well it seems that on the project that Bill did with this NSPopover it works ok but the Popover is messed up even in the settings it is set to hide all the controls it is still showing them on the tests. so i guess it is related to the code in the project part.

if you check the x,y in the cellclick event of the listbox, it shows what’s wrong. It seems a mess up with the view coordinates the listbox relies on.

This problem is driving me crazy too. Only on Mac, no problem on Windows and Linux.
If the row is visible the click returns the correct row.
If the user scrolls down and clicks on a row that was previously not visible, the listbox returns the wrong row.
(Actually I think it returns the row that had the X,Y co-ordinates before the scroll)
It has to be the first click in the listbox ie. open the program, scroll and click. After that it works fine.

System.Gestalt is used in NSPopover albeit being not available is OS X anymore. Solution:

Line 9 in NSPopover:

if keyboard.asyncOptionKey = false and rvalue >= 1070 then

Replace it with:

if false then

[quote=246508:@Aurelian Negrea]Here is a project demo that has the issue . I`m guessing as well that is something related to the NSPopup inheritance as i see that it overrides the select color and as well this select issue.

Thanks .[/quote]

Here is a workaround for the listbox selection, together with a possible way to compensate for other events or get the cell clicked (second line in MouseUp) :

Function MouseDown(x As Integer, y As Integer) As Boolean return true End Function

Sub MouseUp(x As Integer, y As Integer) me.selected(me.RowFromXY(x,y)) = False me.selected(me.RowFromXY(x,y+me.RowHeight)) = True End Sub

Gestalt is still available, even if deprecated.

I just tested it in the beta of 2016R1 under 10.11.4.

Yes, but it runs the wrong code in NSPopover.Constructor. The error will go away when branching to the else part instead of the if part.

BTW my listbox is inside a rectangle if that makes a difference.

Oh yes. You spotted the bug. Thank you.

@Aurelian, this is the solution.

[quote=248577:@Craig Grech]This problem is driving me crazy too. Only on Mac, no problem on Windows and Linux.
If the row is visible the click returns the correct row.
If the user scrolls down and clicks on a row that was previously not visible, the listbox returns the wrong row.
(Actually I think it returns the row that had the X,Y co-ordinates before the scroll)
It has to be the first click in the listbox ie. open the program, scroll and click. After that it works fine.[/quote]

NSPopover does not exist in Windows and Linux.

If your ListBox is not laying on a Popover, your issue may not be related at all.

I have that in a project without PopOver * (but with HTMLViewer).

I do not tried to understand what happens.

  • I am waiting a Xojo native PopOver before I will use them (if I will ever use them).

@Eli Ott: how is your code supposed to fix the issue? There is a sort of popover done in the else but not a proper one.