[Feature Request] Add TabSelected function #80

Closed
opened 6 months ago 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`.
tslocum referenced this issue from a commit 6 months ago
tslocum closed this issue 6 months ago
Owner

Thanks for suggesting this.

Thanks for suggesting this.
tslocum added the
enhancement
label 6 months ago
Poster

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

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.