Yet Another ListBox Alternative™

I needed to create some custom ListBox-like control for a project this week ( Little ChatGPT Helper ). I made so much progress and am pleased with the result so far that I decided to make the code available:

It supports single-click text editing and growing/shrinking of rows while typing.

19 Likes

Updated the repo with features and bug fixes:

  • Improve positioning of text when entering edit mode
  • New demo: Chat Bubbles
  • Add features to support new demo
  • Internal refactorings

11 Likes

This looks great! Will have to play with it and see what’s what. Thanks, John!

1 Like

THANK YOU!!! Was about to sit down and work out a messenger control layout, will try to use this. Will try this out, and contribute if anything spotted or added.

1 Like

Nice work, well done. Thank you for sharing. :slight_smile:

1 Like

Updating with new functionality: The view will scroll to the insertion point or row that has the text focus. Release notes and GIF demonstration here:

TRCustomListBox works around a verified (macOS) XOJO bug when measuring the lines in a TextArea. Getting an accurate count of the number of lines of text in a TextArea is critical to this control’s functionality:

https://tracker.xojo.com/xojoinc/xojo/-/issues/72962#note_556234

However, it would make things better (simpler, faster) if XOJO could fix this bug in a future release. Please consider upvoting the issue to prioritize it.

4 Likes

Thanks forcsharing @John_Balestrieri

Anyone else tried this on a Win machine ? When I did I got some drawing issues and incredibly slow scrolling.

Will try again and post images when at machine but it was Win 10 in my case.

Same for me, works ok for Mac, but drawing issues persist as well as incredibly slow scrolling. Win10 in my case too.

Same here on windos 11

@Sunil_Abraham @Sveinn_Runar_Sigurdsson

Thank you for the Windows feedback. I will look into the Window 11 issues today; I’m curious, but I’m developing primarily on and for Mac. I’m not surprised there’s slow scrolling: Giving the options to render via Graphics (doing all font metrics) and using a TextArea, Graphics didn’t have 100% of the functionality needed. Using a Graphics object may result in faster scrolling/rendering, but IIRC, there were differences between word wrap in Graphics vs the Text Area, and border/inset differences between the two, which, Critically, affected how the height of multi-line rows were as calculated.

Additionally, the Chat Bubbles demo may be slower because it does extra processing to calculate text widths.

Indeed, it’s a mess on Windows:

Transparent TextArea background issues aside, there are fundamental differences between how TextArea renders in the window as a control and how it renders with Graphics.DrawInto, resulting in different text widths, line heights, and word wrappings.

Drawn:

Real Text area:

I bet declares or MBS plugins could improve this situation, but unfortunately, it’s out of scope for me. But, I’m happy to work with a Windows XOJO developer if there are possible improvements.

1 Like

Nice work

I had conditions to open and run the demo with Xojo 2022 R1.
Some visual problems I experimented with text that doesn’t appear in the bubbles, but clicking on the bubble it appears…
So I tried to open and run the demo with Xojo 2022 R4.1 and also with Xojo 2023 R1.1 but it shows me a compilation error:

My Mac have:

This is a problem between High Sierra and newer versions of Xojo and not a problem of the listbox subclass. Just try a new project and you will find the same problem.

2 Likes

+1. xojo versions since around september 2022 cannot compile anymore under high sierra.
you need to update your macos…

1 Like

Thanks @Beatrix_Willius and @Jean-Yves_Pochez