Using themes, setting Selected Foreground on TAB fails to change foreground color as defined in theme

19 views
Skip to first unread message

shop.servic...@gmail.com

unread,
Apr 3, 2019, 2:38:17 PM4/3/19
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA NetBeans 8.2
Desktop OS Windows 10 Pro
Simulator Latest
Device PC, Android & IOS

I am looking to set the selected Color of a Tab (Tabs Object) when selected.

I set the selected ForeGround color to say Green

However the Selected Tab does not change color when selected so there is no visual way to see which tab has been selected.

I am using this model:
            Tabs tb = new Tabs(Component.TOP) {
                @Override
                protected Component createTab(String title, Image icon) {
                    SpanButton custom = new SpanButton(title);
                    custom.setIcon(icon);
                    custom.setUIID("Container");
                    custom.setTextUIID("Tab");
                    custom.setIconPosition(BorderLayout.NORTH);
                    custom.setIconUIID("Tab");
                    return custom;
                }
                @Override
                protected void setTabSelectedIcon(Component tab, Image icon) {
                    ((SpanButton) tab).setPressedIcon(icon);
                }
                protected void selectTab(Component tab) {
                }
                @Override
                protected void bindTabActionListener(Component tab, ActionListener l) {
                    ((SpanButton) tab).addActionListener(l);
                }
            };
            tb.setTabUIID(null);

I have changed the custom.setUIID("Container"); to a theme where selected foreground is green, where unselected is black


Regards

Shai Almog

unread,
Apr 4, 2019, 12:34:09 AM4/4/19
to CodenameOne Discussions
That won't work since the Tab UIID is re-set every time we switch a tab to switch Tab/TabPressed.
You can use tabs.setTabUIID(null) to disable this behavior.

shop.servic...@gmail.com

unread,
Apr 4, 2019, 5:02:34 PM4/4/19
to CodenameOne Discussions
Perhaps I did not explain my issue.

I have used this Above example and set : "tb.setTabUIID(null);" as suggested.

As I investigated further, it appears this method of overriding the Tabs class with SpanButton is where the Selected Tab does not seem to recognize that it is "selected"

The UIID theme has selected, unselected and Pressed colors defined.
Only the Unselected and Pressed states trigger events that conform to the defined color states.
I have confirmed the Tabs class does indicate the correct index selected, (tb.getSelectedIndex()) just that the color defined in custom.setTextUIID("mpiTabMetal") ; is not utilized.

Thoughts?

Shai Almog

unread,
Apr 4, 2019, 11:52:27 PM4/4/19
to CodenameOne Discussions
Tabs only use the pressed/unselected states as they are normally toggle buttons. I'm not aware of an issue there but it could be, I'll need a test case in the issue tracker to see if there's an issue.
Reply all
Reply to author
Forward
0 new messages