[GH-ISSUE #507] Unable to get focus on second DropDown widget in one Flex column #369

Closed
opened 2026-03-04 01:04:23 +03:00 by kerem · 1 comment
Owner

Originally created by @emicklei on GitHub (Oct 3, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/507

Hi,

This example program below shows two DropDown widgets, each with two options, with a layout using a Flex.

Problem:
When running the program, it is not possible get the focus on the second DropDown, either by TAB or using Mouse.

Version:

github.com/rivo/tview v0.0.0-20200915114512-42866ecf6ca6

package main

import (
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	inputDevice := tview.NewDropDown().
		AddOption("abc", nil).
		AddOption("def", nil).
		SetFieldWidth(10)

	outputDevice := tview.NewDropDown().
		AddOption("123", nil).
		AddOption("456", nil).
		SetFieldWidth(10)

	settings := tview.NewFlex().SetDirection(tview.FlexColumn).
		AddItem(inputDevice, 0, 1, true).
		AddItem(outputDevice, 0, 1, true)

	top := tview.NewFlex().SetDirection(tview.FlexRow).
		AddItem(settings, 0, 1, true)

	if err := app.SetRoot(top, true).SetFocus(top).EnableMouse(true).Run(); err != nil {
		panic(err)
	}
}
Originally created by @emicklei on GitHub (Oct 3, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/507 Hi, This example program below shows two DropDown widgets, each with two options, with a layout using a Flex. Problem: When running the program, it is not possible get the focus on the second DropDown, either by TAB or using Mouse. Version: `github.com/rivo/tview v0.0.0-20200915114512-42866ecf6ca6` ``` package main import ( "github.com/rivo/tview" ) func main() { app := tview.NewApplication() inputDevice := tview.NewDropDown(). AddOption("abc", nil). AddOption("def", nil). SetFieldWidth(10) outputDevice := tview.NewDropDown(). AddOption("123", nil). AddOption("456", nil). SetFieldWidth(10) settings := tview.NewFlex().SetDirection(tview.FlexColumn). AddItem(inputDevice, 0, 1, true). AddItem(outputDevice, 0, 1, true) top := tview.NewFlex().SetDirection(tview.FlexRow). AddItem(settings, 0, 1, true) if err := app.SetRoot(top, true).SetFocus(top).EnableMouse(true).Run(); err != nil { panic(err) } } ```
kerem closed this issue 2026-03-04 01:04:24 +03:00
Author
Owner

@emicklei commented on GitHub (Oct 8, 2020):

By inspecting the code, it appears that these widgets need to be part of a Form in order to respond to Tab navigation. I am now considering creating a FlexForm to combine behaviors

<!-- gh-comment-id:705374904 --> @emicklei commented on GitHub (Oct 8, 2020): By inspecting the code, it appears that these widgets need to be part of a Form in order to respond to Tab navigation. I am now considering creating a FlexForm to combine behaviors
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#369
No description provided.