Open theduke opened 4 years ago
Hi, and thanks for the report!
It's possible the items in the list are not focusable. TextView
for example will not be focusable; in that case the focus always come back to the EditView since it's the only view that accepts focus. Maybe you want to have buttons instead?
Note that ListView is now mostly a legacy view that can be in many cases replaced with a simple LinearView or a SelectView.
As for some extra documentation, you're absolutely right! I'll prepare something.
Right now there's no easy way to notify a view that it lost focus.
Note that if you implement your own view, you can check printer.focused
to change the style depending on the focus state.
Right now I added a paragraph to the view
module: https://github.com/gyscos/cursive/blob/6244d6e28c122ae2091e1b2bf6b2b088659106da/src/view/mod.rs#L37
At some point I'll need to re-organize the wiki and doc comments into something more readable...
Cursive is awesome.
The only thing I'm struggling with, and where I haven't seen much information in the code, is on focus management.
It would be great to have a tutorial or some more docs on how this is supposed to be handled.
For example, I have a "page" that has a hierarachy like this:
Note: this is simplified, there are a few
BoxView
etc inbetween.Now what I'd like to do is just use Tab to cycle through the
EditView
and the individualList
items.By default, nothing seems to happen. The Edit has focus and I can't switch to anywhere.
So I tried to used a
OnEventView
to callc.focus_id(ID_OF_LIST_VIEW)
, and would expect the first list item to be selected, but that doesn't seem to work either.Any help for this specifically, and a general explanation would be much appreciated.