Closed rednoah closed 4 years ago
I've also run into this issue!
If this feature doesn't exist, I could hopefully provide a patch for it (although I might need a bit of guidance).
Indeed, only vertical scroll is currently implemented: https://github.com/mabe02/lanterna/blob/master/src/main/java/com/googlecode/lanterna/gui2/AbstractListBox.java#L363
If I'm not mistaken, a CheckBoxList always is a vertical list of checkboxes. That's why it scrolls only vertically. A need to scroll such a list sideways means that one has provided too long labels to each checkbox ;-)
On Thu, May 28, 2020 at 3:14 PM Reinhard Pointner notifications@github.com wrote:
Indeed, only vertical scroll is currently implemented:
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mabe02/lanterna/issues/485#issuecomment-635342356, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIDBMTBXYLMCHRAT3SMLBDRTZPTRANCNFSM4NMZFADA .
@avl42 correct :)
In my case, the labels in the checkbox are file paths, which can be of variable length, and the checkbox has its own window (I implemented a checkboxListDialog, which I plan to submit upstream eventually :))
As a result, an exception would be thrown if the labels were so long that the checkbox list's window would expand past the size of the terminal (or something similar, I can give the exact stack tracer tonight).
The workaround was to limit the size of the checkboxListDialog's window, however, this means that certain labels aren't fully-readable as they exceed the maximum-visible length.
I'm not sure if this is a good enough use case to require horizontal scrollbars though, maybe there's a workaround?
@rednoah what's your use case? I'm curious if you're facing a similar issue.
Essentially the same use case as @AObuchow I suppose. File paths. Not generally a problem, but some users do have crazy long file paths for some reason, and then CheckBoxList
will just cut things off. Oddly enough, the "Terminal is too small. Use ALT+LEFT/RIGHT to scroll." behaviour doesn't kick in either.
e.g.
I'm tempted to think of "good ol' norton commander" or midnight commander on unix. You have panels of files, and if filenames are too long, they are shortened with maybe the begin, the end, or some middle part being replaced by "..."
Even if the user needs to be able to see the full 256 chars or longer filename, I'd probably instead let the labels themselves scroll (with cursor right/left), while leaving the "[ ]" checkboxes fixed against horizontal scrolling.
Unfortunately, however, if you need it, you need to implement it yourself, as of Lanterna's current state.
On Thu, May 28, 2020 at 4:25 PM Andrew O. notifications@github.com wrote:
@avl42 https://github.com/avl42 correct :)
In my case, the labels in the checkbox are file paths, which can be of variable length, and the checkbox has it's own window (I implemented a checkboxListDialog, which I plan to submit upstream eventually :) ) As a result, an exception would be thrown if the labels were so long that the checkbox list's window would expand past the size of the terminal (or something similar, I can give the exact stack tracer tonight).
The workaround was to limit the size of the checkboxListDialog's window, however, this means that certain labels aren't fully-readable as they exceed the maximum-visible length.
I'm not sure if this is a good enough use case to require horizontal scrollbars though, maybe there's a workaround?
@rednoah https://github.com/rednoah what's your use case? I'm curious if you're facing a similar issue.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mabe02/lanterna/issues/485#issuecomment-635382712, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIDBMSKVDJHRZ6ZRWS6633RTZX6DANCNFSM4NMZFADA .
I'm tempted to think of "good ol' norton commander" or midnight commander on unix. You have panels of files, and if filenames are too long, they are shortened with maybe the begin, the end, or some middle part being replaced by "...".
I'm actually making a type of Norton Commander clone, and have this implemented with a ListItemRenderer
:D
Even if the user needs to be able to see the full 256 chars or longer filename, I'd probably instead let the labels themselves scroll (with cursor right/left), while leaving the "[ ]" checkboxes fixed against horizontal scrolling. Unfortunately, however, if you need it, you need to implement it yourself, as of Lanterna's current state.
Okay I'll go with this approach. I assume there's no way to do this with a ListItemRenderer
correct? I'd have to override the labels of the checkbox (if that's possible?).
I've looked into Table
which does seem to implement vertical scroll, but at least in my test case vertical scrolling didn't work, rows are just cut off, with no scrollbars or sideway scrolling. I'll look into it again some other time.
@AObuchow yes, unfortunately there is no native support for horizontal scrolling of list item labels. There is a ScrollBar component you can use, but you'll have to implement your own renderer (with scrolling state) for the listbox and then hook that up to the scrollbar.
@mabe02 that's fine with me :) I'll use the approach you described and let you know how it goes.
Closing this issue in favour of the generic ScrollPanel
feature request:
https://github.com/mabe02/lanterna/issues/490
Does
CheckBoxList
support Horizontal Scrollbar? I can't seem to figure out how to make aList
that can scroll both vertically and horizontally.