Enlarged Listbox doesn't capture mouseclick

This problem has just appeared. I haven’t used this control on Windows since API 2.0 so.
I have a listbox that grows when a mouse enters it. I noticed I shouldn’t use expanded since that’s tied to hierarchical and this isn’t. It also works on Mac quite well.

The mouse click is being passed through to controls that are underneath. The only time the mouse is captured is if it is on the scrollbar.

I did a quick search on Feedback for Listbox, mouse and click and nothing showed.


I checked with an older version and I have the same problems.
So, here’s the code for enlarging my listbox from the MouseEnter


me.SelectedRowIndex = GrLstIdx
me.Selected(me.SelectedRowIndex) = True
Var ht As Integer = me.RowHeight * (me.LastRowIndex)
If ht > me.Top - self.Height - 20 Then
Var ct As Integer = ( self.Height - me.Top - 20 ) \ me.RowHeight
ht = ct * me.RowHeight
me.Height = ht
End If

some events have a boolean return value, do you used it?

Thank you
This one is just return.

A further clarification. I decided to use a listbox because I wasn’t happy with a combobox. I wanted a search in the first cell, which I wasn’t happy with in the ComboBox. The problem hadn’t JUST appeared as I started using this in 2018, but I didn’t really care because I was on my Mac, and it works correctly on Mac.

This is an image on my Mac. The mouse also works on the Mac

Wow. I can upload photos from my computer. Now do I have to keep them in that spot?

  1. I assume Foreign Sentence is a text area? If not, what control is it?
  2. Is the listbox infront of the Foreign Sectence control at design time? (see ordering buttons at top of ide when editing window) 2017-04-14_20-10-35
  3. Is the listbox sitting directly on the window or is it embedded in another control?
  4. Do you use any other code to interacting with the position of the listbox?

No, they are on the forum server after the upload.

The listbox covers (but not in front of) several controls. Each of these controls will fire from a mouse-click above it in the listbox. If there is no code to fire, (I have no code in the window) nothing happens in either uhmm body.

I have never used that option, so it would, I guess, be on the same plane. When I clicked on that “in front of”, button it stayed down. I haven’t tested it. Thank you for the suggestion.

  1. [quote=“anon20074439, post:6, topic:54956”]
    Is the listbox infront of the Foreign Sectence
    The Listbox is not embedded in another control.

  2. [quote=“anon20074439, post:6, topic:54956”]
    Do you use any other code to interacting with the position of the listbox?

All of the code is self-contained, and also for each control, controlling the firing. No control or even method tells the listbox what to do.

Another mouse problem, the mouse wheel works properly on a Mac and changes the visible area. On Windows, it has no effect at all.

Also, if I cursor down and change the SelectedRowIndex, then it works correctly.

I did a small test project with only two controls, ListBox and TextArea. I had no problems. This is unfortunately another problem of scale of too many lines of code, or controls, or windows.

Maybe it’s time to use containercontrols?

That was my next suggestion but if this works as expected then it must be something in the original project. My next suggestions would be:

  1. Search the project for declare to make sure you haven’t forgotten something that you did a long time ago which could be causing this problem only in windows.

  2. Try opening this project and a new blank project at the same time, then copy the listbox and paste it into the new project to make sure that all the listbox settings are copied across as it might be a setting of the listbox that it causing the issue, then do the same thing with one of the textareas.

  3. Try commenting out blocks of code until you find the block that causes the issue.

  4. You’re welcome to PM send me the project and I can take a look if you want.

I finally decided to add breakpoints on the start of various events.
The two weird things that happened on clicking in the Listbox were
Half of the time the first TextArea, which had focus would fire gotfocus even though I clicked on the ListBox.
The other is I am using MouseUp to get the row, instead of CellClick. When it did the RowFromXY and Column it returned a -1. I think it got the correct location (400 and something)

How could it get -1?

Edit a few minutes later
Hmm I ran into a similar problem a couple of years ago and I think I might try my solution from then - move stuff to CellClick.

Here’s the link.

I didn’t realise you use a MouseUp event as I don’t think you mentioned it. I’ve been tailoring the help related to you just using a MouseEnter event and standard listbox behaviour. Doh!

-1 is returned when you aren’t clicking on a cell so your numbers being passed to RowFromXY might be incorrect, could you post your MouseUp code?

Hmmm, do you have a MouseEnter on the textareas?

If you use mouseUp you must
Return True
In the mousedown event, otherwise it won’t do what you want and let’s the system or xojo decide what to do.

No, that’s possible as part of the new Forum.

The Listbox is called GrmLstBox for grammar list box.
The seven events I have CellKeyDown, GotFocus, KeyDown, MouseDown, MouseEnter, MouseExit, MouseUp.
I won’t bother to show CellKeyDown and KeyDown since they don’t have anything to do with mouse events.
BeingEdited is a property which is set to True when the relevant controls are turned to being editable.
The -1 value is in the very first few lines of MouseUp


If BeingEdited Then
me.SelectedRowIndex = GrLstIdx
Var ht As Integer = me.RowHeight * (me.LastRowIndex)
If ht > me.Top - self.Height - 22 Then
me.Height = self.Height - me.Top - 22
me.Height = ht
End If
End If
Return// End of GotFocus ++++++++++++++++++++++++++++++++++

Return True
End of MouseDown+++++++++++++++++++++++++++++

Start of MouseUp ++++++++++++++++++++++++++++++++++
Var row As Integer = me.RowFromXY( x, y )
Var column As Integer = me.ColumnFromXY( x, y )
me.SelectedRowIndex = row
//row and column are -1 here

If row = 0 Then
me.CellTypeAt( row, column ) = Listbox.CellTypes.TextField
ElseIf row > 0 then
GrLstIdx = row //the row selected and saved for scrollposition
Var prp As Boolean = False
Var trsf As New RowGrmClass(MnStuff.GrXCnt)//the class which will fill the listbox with text.

Var rt As Integer = me.RowTagAt(me.SelectedRowIndex)
trsf = GrmInst.GetTrGrRw(rt, False )//the class
If -1 <> CREdit(kCGrmNt).Value.IndexOf(trsf.dagta(GrmCol)) Then prp = True////TextArea related to GrmLstBox

If prp And 7 = App.MyMsgBx( “Your Grammar Word is in the Field Already. Do You Wish to Continue?”, False, self ) Then Return//MyMsgBox is simply a MessageDialog

CREdit(kCGrmNt).Value = if( CREdit(kCGrmNt).Value.IsEmpty = False, CREdit(kCGrmNt).Value + "; " + trsf.dagta(GrmCol), trsf.dagta(GrmCol))

me.Selected(row) = True
CREdit(kCGrmNt).SetFocus//TextArea related to GrmLstBox
End If//me.SelectedRowIndex > 0 then
End of MouseUp+++++++++++++++++++++++++++++++++

Start of MouseEnter ++++++++++++++++++++++++++++++++++++
If BeingEdited Then
me.SelectedRowIndex = GrLstIdx
me.Selected(me.SelectedRowIndex) = True
Var ht As Integer = me.RowHeight * (me.LastRowIndex)
If ht > me.Top - self.Height - 20 Then
Var ct As Integer = ( self.Height - me.Top - 20 ) \ me.RowHeight
ht = ct * me.RowHeight
me.Height = ht
End If
End If
End of MouseEnter+++++++++++++++++++++++++++++++++++

Start of MouseExit++++++++++++++++++++++++++++++++++++
If me.RowHeight > 22 Then
me.Height = me.RowHeight
me.Height = 22
End If
me.ScrollPosition = me.SelectedRowIndex
End of MouseExit++++++++++++++++++++++++

I just set up a window with most of your code in there and I don’t see a problem if I’m understanding the problem (a video would be nice).

When you say “click through” do you mean that the listbox’s MouseUp event doesn’t fire or that the caret appears in the text area behind the control?

If you have some MouseOver code in the textarea under the listbox then this will fire when the mouse is not technically over the textarea and is still in the listbox, I consider that to be a bug in the framework and is probably a remnant of the old front to back ordering way controls were rendered.

Side note, I had to change to this to get the scrollbar working:

Function MouseDown(x As Integer, y As Integer) Handles MouseDown as Boolean
  Return Me.RowFromXY(x, y) <> -1 'Allow MouseUp to fire only if we clicked a valid row
End Function

If you can alter the following project to show the problem, please feel free.

Julian. No Disrespect.
I decided to change it to a ComboBox and all of my headaches disappeared.
I also don’t have the SegmentedControls poking through the ComboBox like I did with the enlarged ListBox. They literally showed through.
I believe this problem is a problem of scale of either too many lines of code or too many windows. My code in the XML is about 2.6 Mb. I have a feedback case with the MessageBox and I was able to pare it down to about 1 Mb. I won’t be able to reproduce this easily.

I also appreciate the piece about the ScrollBar. I might get that to work. Later.

I have a couple of more bugs to get rid of and I can show my monsterpiece

No worries :slight_smile: