How do you detect a long click on a ListField component?
Do you override its navigationClick(int status, int time) and fumble with its time argument (how?) or is there some builtin method for detecting long clicks?
And more importantly - how do you display the menu (the one in the middle of the screen) once you detected such a click?
The background is that on short clicks I'd like to let the user edit the selected item. And on long clicks I'd like to display a menu in the middle of the screen to offer secondary tasks: delete item, change item display order, etc.
Below is my current test code - src\mypackage\MyList.java:
package mypackage;
import java.util.*;
import net.rim.device.api.collection.*;
import net.rim.device.api.collection.util.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.decor.*;
import net.rim.device.api.util.*;
public class MyList extends UiApplication {
public static void main(String args[]) {
MyList app = new MyList();
app.enterEventDispatcher();
}
public MyList() {
pushScreen(new MyScreen());
}
}
class MyScreen extends MainScreen {
ObjectListField myList = new ObjectListField() {
protected boolean navigationClick(int status, int time) {
System.err.println("XXX status=" + status + ", index=" + getSelectedIndex());
return true;
}
};
public MyScreen() {
setTitle("How to detect long click?");
myList.set(new String[] { "Item 1", "Item 2", "Item 3", "Item 4", });
add(myList);
}
}
Thank you Alex