[Urwid] Set focus to top, middle or bottom item in Listbox
ian at excess.org
Wed Jul 17 11:13:08 EDT 2013
On Wed, Jul 17, 2013 at 9:00 AM, <naglis at lavabit.com> wrote:
> I'm fairly new to urwid and I'm trying to implement a vi-like navigation
> with keyboard shortcuts H, M, L where H sets focus to the top currently
> visible item, M - to the middle one, and L - to the bottom one. However,
> I'm struggling to get correct results. I've tried to extend my Listbox by
> adding a size attribute to it (I've seen this in a previous mailing list),
> and then using it to calculate the position of the top, middle, bottom
> currently visible item. However, this method fails if a list item
> occupies more than on line on the screen.
> I was wondering if someone else had solved this problem or has any tip
> about how this can be done correctly.
One way would be to send the ListBox a mouse click event, I believe
that will set the focus/cursor position.
If not, look at the mouse_event code in ListBox and modify it to suit
More information about the Urwid