mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #95] Trouble with the implicit SetFocus() #73
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#73
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @snabb on GitHub (Mar 30, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/95
I had trouble setting focus when using a Table within a Flex. The following code does not work:
The focus is not in the table. I can not move between the table rows.
If I change the
app.SetFocus(w2)call to the following it works:I browsed through all the closed issues and in one of them it was mentioned that
app.SetRoot(foo, false)implicitly callsapp.SetFocus(foo). How can I work around this? Would it make sense to eliminate the implicitapp.SetFocus()call and let the user set the focus? (Or perhaps I am missing something obvious?)PS. Great stuff!
@rivo commented on GitHub (Apr 1, 2018):
You'll want to pass
truein theAddItem()call for your table:The application will initially set the focus to the
Flexelement. But then theFlexelement will pass the focus on to your table. See the documentation for details.Alternatively, you can also call
SetFocus()betweenSetRoot()andRun():Let me know if this helps.
@snabb commented on GitHub (Apr 1, 2018):
I figured out the
AddItem(x, x, x, true)method. It feels troublesome, because I need to define the full "path" through several Flex'es (if the application has many Flex'es within each other) instead of just telling which widget should have focus initially.However calling
app.SetFocus()afterapp.SetRoot()is easy and straight-forward. I apologize for not figuring this out.Again: Great stuff! Thanks for making this package available!