eclipsesource / eclipsesource/tabris

Swipes to non-zero SwipeItems don't get triggered

Open
#472 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
56
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Using a Swipe in Tabris for RAP 3.6, I cannot swipe to anything other than the initial 0-indexed page. Swipe events don't get triggered and it never requests the next page.

Example code here:
`/* DEMONSTRATES TABRIS TABS - demonstrates swipe bug 2.7 - swipes to other pages never gets triggered */
package bug.snippet;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
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.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

import com.eclipsesource.tabris.widgets.swipe.Swipe;
import com.eclipsesource.tabris.widgets.swipe.SwipeContext;
import com.eclipsesource.tabris.widgets.swipe.SwipeItem;
import com.eclipsesource.tabris.widgets.swipe.SwipeListener;

public class Bugsy {
private Display display;
private Shell shell;
Composite comp;
Button butAdd;
Button butRemove;
Swipe swipe;
Label count;
MySwipeItemProvider myItemProvider;

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;

// create the composite
comp = new Composite(shell, SWT.BORDER);
comp.setBackground(new Color(null, 255,0,0));

// set comp'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(75,-10);
comp.setLayoutData(fd);

layout = new FormLayout();
comp.setLayout(layout);

// create the buttons
butAdd = new Button(shell, SWT.PUSH);
butAdd.setText("Add Page");
butRemove = new Button(shell, SWT.PUSH);
butRemove.setText("Remove Page");

// set buttons' position
fd = new FormData();
fd.left = new FormAttachment(0, 10);
fd.top = new FormAttachment(75, 10);
fd.right = new FormAttachment(50,-10);
fd.bottom = new FormAttachment(100,-40);
butAdd.setLayoutData(fd);

fd = new FormData();
fd.left = new FormAttachment(50, 10);
fd.top = new FormAttachment(75, 10);
fd.right = new FormAttachment(100,-10);
fd.bottom = new FormAttachment(100,-40);
butRemove.setLayoutData(fd);

// create the label - shows current count of items in swipe

count = new Label(shell, SWT.NONE);
count.setText("0 swipe items");

fd = new FormData();
fd.left = new FormAttachment(0, 10);
fd.top = new FormAttachment(100, -35);
fd.right = new FormAttachment(100,-10);
fd.bottom = new FormAttachment(100,-5);
count.setLayoutData(fd);

// add the swipe control

myItemProvider = new MySwipeItemProvider();
swipe = new Swipe(comp, myItemProvider);

fd = new FormData();
fd.left = new FormAttachment(0, 5);
fd.top = new FormAttachment(0, 5);
fd.right = new FormAttachment(100,-5);
fd.bottom = new FormAttachment(100,-5);
swipe.getControl().setLayoutData(fd);

butAdd.addListener(SWT.Selection, listenerButAdd);
butRemove.addListener(SWT.Selection, listenerButRemove);

swipe.addSwipeListener(swipeListener);

shell.open();

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

SwipeListener swipeListener = new SwipeListener() {
@Override
public void itemLoaded(SwipeItem item, int index) {
}

@Override
public void itemActivated(SwipeItem item, int index, SwipeContext context) {
count.setText(myItemProvider.getItemCount() + " swipe items with activeId: " + myItemProvider.activeItemId);
}

@Override
public void itemDeactivated(SwipeItem item, int index, SwipeContext context) {
}

@Override
public void disposed(SwipeContext context) {
}
};

Listener listenerButAdd = new Listener() {
public void handleEvent(Event event) {
myItemProvider.addItem();
count.setText(myItemProvider.getItemCount() + " swipe items with activeId: " + myItemProvider.activeItemId);
if (myItemProvider.getItemCount() == 1) swipe.show(0);
swipe.refresh();
}
};

Listener listenerButRemove = new Listener() {
public void handleEvent(Event event) {
if (myItemProvider.getItemCount() == 0) return;
System.out.println("REMOVE active: " + myItemProvider.activeItemId + " count: " + myItemProvider.getItemCount());
if (myItemProvider.activeItemId == myItemProvider.getItemCount()) {
// set current page to be 2nd-to-last as we are about to remove the last one
swipe.show(myItemProvider.activeItemId-2);
}
myItemProvider.removeLastItem();
count.setText(myItemProvider.getItemCount() + " swipe items with activeId: " + myItemProvider.activeItemId);
swipe.refresh();
}
};

}
`

Problem occurs on iOS.
Android seems to swipe OK in most cases.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.