eclipsesource / eclipsesource/tabris

Android Tabris 1.2 dropdown Combo cannot have no selection

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

Description

Not sure if this is deliberate, but on Android is it impossible to have a Combo dropdown that doesn't have a value selected (assuming there are values to choose from).

All other platforms, if I don't do a .setText() on the Combo, it remains blank until I select something, but on Android it always defaults to the first item in the list.

Snippet below.

/\* DEMONSTRATES TABRIS PROBLEM WITH COMBOS WITH NO VALUE ON ANDROID*/
package bug.snippet;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.rap.rwt.service.ServerPushSession;
import org.eclipse.swt.SWT;
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.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class Bugsy {
private Display display;
private Shell shell;
private Combo combo;
private List comboValueList;

```
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 Combo
combo = new Combo(shell, SWT.DROP_DOWN);

//set Combo's position
fd = new FormData();
fd.left = new FormAttachment(0, 10);
fd.top = new FormAttachment(0, 50);
fd.right = new FormAttachment(0, 200);
//fd.bottom = new FormAttachment(100,-10);
combo.setLayoutData(fd);
combo.addListener(SWT.Selection, listener);

final ServerPushSession pushSession = new ServerPushSession();
pushSession.start();

comboValueList = new ArrayList();
comboValueList.clear();
comboValueList.add("item1");
comboValueList.add("item2");
comboValueList.add("item3");
combo.setItems((String[]) comboValueList.toArray(new String[comboValueList.size()]));

shell.open();

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

Listener listener = new Listener() {
public void handleEvent(Event event) {
int i = combo.getSelectionIndex();
String s = combo.getItem(i);
System.out.println("SELECTED: " + s);
}
};
```

}

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.