Open Claudio08 opened 4 years ago
I'm not so sure about this one... Changing tab text regularly is not a particularly desirable thing from a user point of view, in the way we have intended tabs to be used.
Perhaps you can expand on the usage you have so we can see how frequently it would be requested?
For example, if we have to change the texts of a mask because the user select another language (from english to another) have this method as standard in the widget may be usefull. For the moment, i use it only for a particular use in a little project that i am writing to learn Fyne.
Selection of another language is a much bigger problem that we have to tackle toolkit wide!
Maybe this makes more sense now that we have DocTabs? Changing the tab name to the command being run inside a terminal for example or the name of a text file, is quite a common use case out there.
Hope that it will be possible to add as enhancement in "standard widget.TabContainer" the possibilty to set/change the "Text of current TAB" and a "TAB text by index position".
Sometimes is necessary to change the text of a tab at runtime, to do this now we can use: TabContainer.CurrentTab().Text = "xyz" TabContainer.Refresh()
may be that a dedicated method is more elegant. I think that these methods can interest to other Fyne developers.
I write a myTabContainer widget and added these functions, may be that a similar code, with adeguate methods names, can added to the standard TabContainer widget:
//----custom TabContainer---- type myTabContainer struct { widget.TabContainer } func NewMyTabContainer(items ...widget.TabItem) myTabContainer { tab := &myTabContainer{} tab.ExtendBaseWidget(tab) return tab } // //Set current Tab text func (c myTabContainer) SetCurrentTabText(s string) { c.CurrentTab().Text = s c.Refresh() } // //Set Tab text by index position func (c myTabContainer) SetTabTextByIndex(index int, s string) { if index < 0 || index >= len(c.Items) { return }
c.Items[index].Text = s c.Refresh()
} //----END