[Feature Request] Add TabSelected function #80

Closed
opened 2021-11-09 21:36:33 +00:00 by caninodev · 2 comments

Panels has a SetChangedFunc, expose this for TabbedPanels such that when the user has selected a Tab, a function will be executed.

Use Case:

Let's say I have a TabbedPanel that consists of a Flex containing a List and TreeView. When .SetCurrentTab(name) is called, it will call a function to update the associated List.

`Panels` has a `SetChangedFunc`, expose this for `TabbedPanels` such that when the user has selected a Tab, a function will be executed. Use Case: Let's say I have a `TabbedPanel` that consists of a `Flex` containing a `List` and `TreeView`. When `.SetCurrentTab(name)` is called, it will call a function to update the associated `List`.
Owner

Thanks for suggesting this.

Thanks for suggesting this.
tslocum added the
enhancement
label 2021-11-12 23:18:55 +00:00
Author

Can you provide clarification as to why the the following behavior is observed:

b.lists is defined as an initialized cview.TabbedPanels
b.states is map of *cview.Lists with the associated tab string name

func (b *Browser) initializeTabbedList() {
	
    b.lists.SetChangedFunc(b.populate)
}

{...}

func (b *Browser) populate() {
	go func() {
    	listStr := b.lists.GetCurrentTab()
        {...}
        b.debugBar.SetText(listStr)
    }()
}

Works as expected. However, should I do the following:

func (b *Browser) populate() {
	listStr := b.lists.GetCurrentTab()
    go func() {
    	{...}
        b.debugBar.SetText(listStr)
    }()
}

will make the application unresposive.

Can you provide clarification as to why the the following behavior is observed: `b.lists` is defined as an initialized `cview.TabbedPanels` `b.states` is map of `*cview.Lists` with the associated tab string name ```go func (b *Browser) initializeTabbedList() { b.lists.SetChangedFunc(b.populate) } {...} func (b *Browser) populate() { go func() { listStr := b.lists.GetCurrentTab() {...} b.debugBar.SetText(listStr) }() } ``` Works as expected. However, should I do the following: ```go func (b *Browser) populate() { listStr := b.lists.GetCurrentTab() go func() { {...} b.debugBar.SetText(listStr) }() } ``` will make the application unresposive.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
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: tslocum/cview#80
No description provided.