eclipsesource / tabris

Tabris for Eclipse RAP
https://eclipsesource.com/products/tabris
53 stars 18 forks source link

iOS TabItems inside ScrolledComposite - buttons do not work #478

Closed JohnGymer closed 5 years ago

JohnGymer commented 5 years ago

If a TabFolder/TabItems are placed inside a ScrolledComposite, you cannot press the TabItem buttons on iOS. Swipe to change tabs works OK, but not the buttons. Android and Windows Tabris clients are OK.

Snippet:

`/ DEMONSTRATES TABRIS TABS - iOS doesn't let you press the tabitems to change tab - only swipe / package bug.snippet;

import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import com.eclipsesource.tabris.widgets.enhancement.Widgets;

public class Bugsy { private Display display; private Shell shell; private ScrolledComposite sComp; private Composite comp; private static TabFolder tf; private static TabItem ti1; private static TabItem ti2; private static TabItem ti3; private static Composite c1; private static Composite c2; private static Composite c3; private static Button b1; private static Button b2; private static Button b3;

public void begin() {
    System.out.println("BugSnippy Starting...");

    // create the Shell
    display = new Display();
    shell = new Shell(display, SWT.NONE);
    shell.setText("Shell");
    shell.setFullScreen(true);
    shell.setBackground(new Color(null, new RGB(255,255,192)));
    FormLayout layout = new FormLayout();
    shell.setLayout(layout);
    FormData fd;

    sComp = new ScrolledComposite(shell, SWT.V_SCROLL);
    sComp.setBackground(null);
    sComp.setLayout(new FormLayout());
    sComp.setExpandHorizontal(true);
    sComp.setExpandVertical(true);
    sComp.setMinSize(300, 300);
    fd = new FormData();
    fd.left = new FormAttachment(0, 10);
    fd.top = new FormAttachment(0, 10);
    fd.right = new FormAttachment(100, -10);
    fd.bottom = new FormAttachment(100, -10);
    sComp.setLayoutData(fd);

    // create Composite to place Combo within
    comp = new Composite(sComp, SWT.NONE);
    comp.setBackgroundMode(SWT.INHERIT_DEFAULT);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    comp.setLayoutData(fd);
    comp.setLayout(new FormLayout());
    comp.setBackground(null);

    sComp.setContent(comp);

    //create the tabfolder
    tf = new TabFolder(comp, SWT.BORDER|SWT.BOTTOM);
    //tf.setBackgroundMode(SWT.INHERIT_DEFAULT);
    tf.setBackground(new Color(null, new RGB(255,127,127)));

    //set tabfolder's position
    fd = new FormData();
    fd.left = new FormAttachment(0, 10);
    fd.top = new FormAttachment(0, 10);
    fd.right = new FormAttachment(100,-10);
    fd.bottom = new FormAttachment(100,-10);
    tf.setLayoutData(fd);
    layout = new FormLayout();
    tf.setLayout(layout);

    ti1 = new TabItem(tf, SWT.NONE);
    ti1.setText("Tab1");
    ti2 = new TabItem(tf, SWT.NONE);
    ti2.setText("Tab2");
    ti3 = new TabItem(tf, SWT.NONE);
    ti3.setText("Tab3");

    c1 = new Composite(tf, SWT.NONE);
    fd = new FormData();
    fd.left = new FormAttachment(0, 10);
    fd.top = new FormAttachment(0, 10);
    fd.right = new FormAttachment(100,-10);
    fd.bottom = new FormAttachment(100,-10);
    c1.setLayoutData(fd);
    layout = new FormLayout();
    c1.setLayout(layout);

    b1 = new Button(c1, SWT.PUSH);
    b1.setText("but1");
    fd = new FormData();
    fd.left = new FormAttachment(0, 10);
    fd.top = new FormAttachment(0, 10);
    fd.width = 200;
    fd.height = 40;
    b1.setLayoutData(fd);

    ti1.setControl(c1);

    c2 = new Composite(tf, SWT.NONE);
    fd = new FormData();
    fd.left = new FormAttachment(0, 10);
    fd.top = new FormAttachment(0, 10);
    fd.right = new FormAttachment(100,-10);
    fd.bottom = new FormAttachment(100,-10);
    c2.setLayoutData(fd);
    layout = new FormLayout();
    c2.setLayout(layout);

    b2 = new Button(c2, SWT.PUSH);
    b2.setText("but2");
    fd = new FormData();
    fd.left = new FormAttachment(0, 20);
    fd.top = new FormAttachment(0, 20);
    fd.width = 200;
    fd.height = 40;
    b2.setLayoutData(fd);

    ti2.setControl(c2);

    c3 = new Composite(tf, SWT.NONE);
    fd = new FormData();
    fd.left = new FormAttachment(0, 10);
    fd.top = new FormAttachment(0, 10);
    fd.right = new FormAttachment(100,-10);
    fd.bottom = new FormAttachment(100,-10);
    c3.setLayoutData(fd);
    layout = new FormLayout();
    c3.setLayout(layout);

    b3 = new Button(c3, SWT.PUSH);
    b3.setText("but3");
    fd = new FormData();
    fd.left = new FormAttachment(0, 30);
    fd.top = new FormAttachment(0, 30);
    fd.width = 200;
    fd.height = 40;
    b3.setLayoutData(fd);

    ti3.setControl(c3);

    Widgets.onTabFolder(tf).usePaging();
    b1.addSelectionListener(selListener);
    b2.addSelectionListener(selListener);
    b3.addSelectionListener(selListener);
    tf.addSelectionListener(selListener);

    shell.open();

    System.out.println("BugSnippy Done!");
}

SelectionListener selListener = new SelectionListener() {
    @Override
    public void widgetSelected(SelectionEvent e) {
        FormData fd;
        FormLayout layout;
        if (e.item != null) {
            if (e.item.equals(ti1)) {
            } else if (e.item.equals(ti2)) {
            } else if (e.item.equals(ti3)) {
            }
        } else if (e.widget != null) {
            if (e.widget.equals(b1)) {
                tf.setSelection(1);
            } else if (e.widget.equals(b2)) {
                tf.setSelection(2);
            } else if (e.widget.equals(b3)) {
                tf.setSelection(0);
            }
        }
    }

    @Override
    public void widgetDefaultSelected(SelectionEvent e) {
    }
};

} `

ifurnadjiev commented 5 years ago

I can confirm this

ifurnadjiev commented 5 years ago

This is issue is fixed in tabris.js 2.x. Please use "tabris": "nightly-2.x" in your app package.json.