How to Change the Text in a Command? #2691
Replies: 1 comment 1 reply
-
I think this is likely in the space between a feature and a bug. It's a bug in as much as it seems obvious that you should be able to change labels; it's a request for a new feature on the basis that nothing in the docs says that this behavior should be possible. When you remove then re-add the toolbar, you're forcing a refresh; hence, the new labels are applied. You'd likely find that you'd have the same effect if you added or removed a single item to the toolbar. This is because there is a listener in place on changes to the toolbar, which causes the whole toolbar to be recreated. So - the simplest "fix" for this would be to modify the property for the command label to trigger an update on any command set it is a part of. The complication here is that the command doesn't know what command sets it is part of. A better fix would be to connect changes in the command label to the refreshing underlying command implementation, which should give you access to the underlying native menu and toolbar items. This would allow the labels for those items to be updated directly. |
Beta Was this translation helpful? Give feedback.
-
REWRITTEN FOR CLARITY:
Hey, there, all,
I've been playing around with the example in section 4.1.4 of the Toga docs. Just for fun, I decided to have the
Action 4
toolbar button change the text in theAction 3
toolbar button.Here are my modifications:
However, the text on
Action 3
didn't change. I threw in aprint()
statement to make sure the change was actually taking place (and it was) but the only way to see the change in the toolbar button was to remove the entire toolbar and put it back... which—of course—causes the UI to 'jump.'Question: Is there a way to change the text that's more straightforward? Like, is there a way to access the
toolbar
button's text directly instead of through theCommand
object?Likewise for the Menu item.
Beta Was this translation helpful? Give feedback.
All reactions