how to scroll to selected TAB

28 views
Skip to first unread message

Mark Bolduc

unread,
Sep 10, 2019, 1:51:42 PM9/10/19
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA Netbeans 11
Desktop OS Windows 10 Pro
Simulator Latest
Device PC, IOS, Android

I have 7 tabs as TOP orientation,

in this example, TAB 0 is selected, (and TABS 5,6,7) are not visible.
I execute setSelectedIndex(7, true) and The Container associated with TAB 7 is now visible, However the TABS did not scroll to the TAB position 7.
How do I force TAB 7 to be visible ( scrollComponentToVisible(TABS) does not work

Regards.

Shai Almog

unread,
Sep 10, 2019, 10:42:17 PM9/10/19
to CodenameOne Discussions
This should work implicitly. I will need more details to understand why this is happening to you... Are you doing it before the code is laid out and ready?

Form f = new Form("Test", new BorderLayout());
Tabs t = new Tabs();
for(int iter = 0 ; iter < 30 ; iter++) {
    t
.addTab("Tab " + iter, new Label("Tab #" + iter));
}
f
.add(CENTER, t);
f
.addShowListener(e -> t.setSelectedIndex(29));
f
.show();


CodenameOne Screenshot 3.png


Mark Bolduc

unread,
Sep 11, 2019, 5:29:16 PM9/11/19
to CodenameOne Discussions
When I build a stand alone model, it behaves as expected.
I have a fully enstanciated TABs component, as a result of user wanting to access the Tab index 7, I execute on the EDT setSelectedIndex(7, true);
So I have no clue why the Tabs fail to scroll to the selected component.

Thoughts?

Shai Almog

unread,
Sep 11, 2019, 11:06:58 PM9/11/19
to CodenameOne Discussions
But do you execute it when the form is already visible after the transition?

Mark Bolduc

unread,
Sep 12, 2019, 10:52:18 AM9/12/19
to CodenameOne Discussions
Yes, I have added 2 OverFlow Commands for a simple case to select / expose tabs that are not currently visible.

        tb.addMaterialCommandToOverflowMenu("Expose Time Sheet Tab", FontImage.MATERIAL_ASSIGNMENT_RETURNED, 3, e -> {
            Display.getInstance().callSerially(new Runnable() {
                public void run() {
                        A3RepairOrderTabsForm.setSelectedIndex(7, true);
                        a3RepairOrderForm.a3ManageTimeSheets.ManageTimeSheetsTab.setSelectedIndex(0, true);
                }
            });
        });
        tb.addMaterialCommandToOverflowMenu("Expose Labor Tab", FontImage.MATERIAL_ASSIGNMENT_RETURNED, 3, e -> {
            Display.getInstance().callSerially(new Runnable() {
                public void run() {
                        A3RepairOrderTabsForm.setSelectedIndex(3, true);
                        a3RepairOrderForm.A3LaborTab.setSelectedIndex(0, true);
                }
            });
        });
See attached image AddTabsGridBool_8.JPG showing the Labor Tab is selected and I confirm the Labor Task Tab is highlighted and correct.
Next I select Expose Time Sheet Tab, See AddTabsGridBool_10.JPG
Note The TOP Layer TABS have not scrolled to the selected index.
When I manually scroll the Tabs, I see that the selected Index is correctly highlighted.

So it is a matter of why the TABS do not scroll. See AddTabsGridBool_11.JPG

Thoughts?
AddTabsGridBool_11.JPG
AddTabsGridBool_10.JPG
AddTabsGridBool_9.JPG
AddTabsGridBool_8.JPG

Shai Almog

unread,
Sep 12, 2019, 10:36:48 PM9/12/19
to CodenameOne Discussions
It's hard to tell with a large app but notice that overflow is a separate form. It might still work but when the overflow menu is shown the current form isn't active anymore. Call serially might not be enough since you would have a transition of showing/hiding the overflow menu.

Another possibility is that rendering/animation/repaint is blocking the animation but because there's a lot of UI here I'm not sure how I can point you in the right direction.
Reply all
Reply to author
Forward
0 new messages