Listbox CellBackgroundPaint Bug?

Hi,

I use this to draw a Listbox-Selection by myself:

[code]If row > ListCount-1 Then Return False

g.ForeColor = &cFFFFFF
g.FillRect 0, 0, g.Width, g.Height

If Me.Selected(Row) Then
g.Pen.Width = 2
g.ForeColor = &c68A2D6
g.DrawRect 3, 3, g.Width-6, g.Height-6
Return True
Else
g.Pen.Width = 1
g.ForeColor = &cC0C0C0
g.DrawRect 3, 3, g.Width-6, g.Height-6
Return False
End If[/code]

If i select the Row via Keyboard, i got this thick ugly gray border. Why? UseFocusRing = False

the focusring is blue, not grey

I said i turned off the FocusRing of the Listbox. :wink:

you should also turn “border” off

Sorry, i don’t know what you mean. I don’t set any border and i need the border around the Listbox, because it do not look nice without border.

It’s on by default. Turn it off in the inspector.
Or Me.Border = False in the .Open event.

try to set g.PenWidth back to 1 before you call return true.

IMO this is a bug.

Set both g.PenWidth to the same value and the problem disappears. By the way it is not g.Pen.Width as you have posted.

Ok, I’m really confused. You’ve already said you need the border around the listbox itself so that isn’t the one you are having issues about. Are you objecting to the borders around the individual unselected cells? If so, you are drawing them in the Else block of your code.

Don’t be confused Dale :slight_smile: i didn’t knew Listboxes had a Border Property at the Inspector. Now i know.

No it’s fixed with the help of Eli Ott, thanks.

[code]If row > ListCount-1 Then Return False

g.ForeColor = &cFFFFFF
g.FillRect 0, 0, g.Width, g.Height

If Me.Selected(Row) Then
g.PenWidth = 2
g.ForeColor = &c68A2D6
g.DrawRect 3, 3, g.Width-6, g.Height-6
g.PenWidth = 1
Else
g.ForeColor = &cC0C0C0
g.DrawRect 3, 3, g.Width-6, g.Height-6
End If

Return True[/code]

[quote=260147:@Martin Trippensee]Don’t be confused Dale :slight_smile: i didn’t knew Listboxes had a Border Property at the Inspector. Now i know.

No it’s fixed with the help of Eli Ott, thanks.

[code]If row > ListCount-1 Then Return False

g.ForeColor = &cFFFFFF
g.FillRect 0, 0, g.Width, g.Height

If Me.Selected(Row) Then
g.PenWidth = 2
g.ForeColor = &c68A2D6
g.DrawRect 3, 3, g.Width-6, g.Height-6
g.PenWidth = 1
Else
g.ForeColor = &cC0C0C0
g.DrawRect 3, 3, g.Width-6, g.Height-6
End If

Return True[/code][/quote]
Make sure you also set PenHeight. They are independent of one another in the old framework.

I’ve been busy with work deadlines, so I haven’t had time to look at the new Betas recently, but I just compiled my main project in the r1.1b4 beta and I am noticing some odd difference in the way the ListBox DrawRect behaves now. I see all kinds of missing borders in some ListBox cells. I usually fire up my main project in the current Beta and usually never see any problems, but this one looks odd. Looks fine in 2015r3.1 which I usually work in. I’m going to try it in 2015r4 to see what it looks like there, but something is different.

Looks fine in 2015r4. I’ll do some more digging.

Works fine in 2015r4.1 as well. Did something change with the ListBox width and height calculations in 2016r1.1 or 2016r1? This line of code in the CellBackgroundPaint event has always been like this in my code for years, to draw a bounding rectangle. Do it for all the cells and you have a grid:

g.DrawRect 0, 0, g.width, g.height

but doesn’t draw the right side and bottom portion of the Rect in 2016r1.1. But if I change it to:

g.DrawRect 0, 0, g.width - 1, g.height - 1

It looks correct to previous versions of Xojo I have worked with. I tried to install 2016r1, but the VCRedist keeps hangings the installer, not sure if I got a bad download. I don’t see anything in the Release Notes to indicate a change, but the behavior is definitely different.

Merv, is that Windows?
g.DrawRect(0, 0, g.width, g.height) is what I always use and it looks ok here on my MBP on 2016r1

I just tried and -1, -1 is really off.

Now I must say that when I draw really tiny stuff (like a 9x9 circle with a character inside), I see a slight difference between my laptop and my iMac. Not with listbox borders though.

Correct Windows 7. g.DrawRect(0, 0, g.width, g.height) is what I always used too, but in 20161.1 it has changed, at least for me on Windows. I haven’t tried it on the Mac yet, still doing some experimenting. If the behavior has changed I’ll file a Bug report tomorrow.

Looks like it is a Windows only issue. The ListBox looks incorrect running natively on Windows 7. But when I Remote Debug over to a Mac 10.9.5 machine, it looks fine in 2016r1.1b4. I’ll work up a Feedback case tomorrow.

Feedback #43544, with small example program. It’s a small thing, but it makes a wreck of a few of my screens so it makes 2016r1.1 unusable.

This issue appears to be fixed in r1.1b6, thanks.