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.
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.
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:
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.
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.
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.
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.
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:
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.