Re: [lanterna-discuss] A custom ListBox

87 views
Skip to first unread message

Martin Berglund

unread,
Jul 17, 2018, 11:15:35 PM7/17/18
to lanterna...@googlegroups.com
Hi Valentin,
Adding color support to a text box is not trivial, right now we store just the text content but in order to have colors and styles we'd need to also keep various kinds of markup information. Contributions are most welcome, I don't have any immediate plans to implement this at the moment. You could probably copy+paste the TextBox code into a new class and start from there. Maybe for your use case, you don't need it to be 100% generic and maybe you can just have it markup special keywords?

Regards,
Martin

Den tis 15 maj 2018 kl 17:37 skrev Valentin Papin <valenti...@gmail.com>:
Hello,

First of all I would like to say that Lanterna is a magic library. Exactly what I was looking for. Implement all these features in pure java, well done Martin ! But as you know, we always want more ...

I would need a custom component, something that looks like RichTextBox in C# (i.ea list box of strings with colors)
Unfortunately the only component that supports the color I found is the Label.
So here is what I tried until now :

  • Using ActionListBox and adding some Labels into it.
    • It calls the toString() method of the Label but doesn't rendering it with its color (displays com.googlecode.lanterna.gui2.Label@xxxxxxxx)
  • Using 2 Panels and a ScrollBar like the ScrollBarTest.
    • I don't know if I can handle keystrokes to set the scrollbar position and scroll labels into the panel.
    • I think that I will have an issue because I suspect that the label is not focusable so maybe no possibility for me to handle keystrokes.

Maybe that I could extend from the AbstractListBox class to make my own component. I guess that I will have to override the drawItem() method.
I know someone has managed to do it with a previous version of Lanterna and then Martin implemented that functionality (Topic link - Achievement)

Am I on the right track? If this is not the case thank you for pointing me out or giving me the list of things to do in order to reach my goal.

--
Det här meddelandet skickas till dig eftersom du prenumererar på gruppen "lanterna-discuss" i Google Grupper.
Om du vill sluta prenumerera på den här gruppen och inte längre få någon e-post från den skickar du ett e-postmeddelande till lanterna-discu...@googlegroups.com.
Fler alternativ finns på https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages