0

In my j2me application for blackberry, I have gridfield and when I click on griditems, I want to select that item with highlighting borders around it which i am able to do it. But now i want to open dialog to select sub category on long press on that item.

I am using navigationclick event to select griditem. but not able to detect long press/touch event when I hold for 2 seconds on griditem. So how to detect long press event so that I can open subcategory dialog based on griditem?

below is my code for selection on griditem when click:

public boolean navigationClick(int status, int time) {  
    isSelected = !isSelected;
    listener.categorySelected(id, isSelected);
    this.invalidate();
    return true;
};

If any idea for double click event then also it's fine for me. I will change functionality for long click to double click in the app.

Mihir Shah
  • 1,799
  • 3
  • 29
  • 49
  • refer this http://stackoverflow.com/questions/6141280/blackberry-6-how-to-detect-a-long-click-on-track-pad – Rince Thomas Apr 23 '14 at 08:03
  • check the time value. if its more than 2 seconds, then perform your action. that will be a long click. – Rince Thomas Apr 23 '14 at 08:41
  • @Signare how can I calculate time? because in parameter time is time - The number of milliseconds since the device was turned on. – Mihir Shah Apr 23 '14 at 12:38
  • @MihirShah - have a 'global' variable that is the time when last clicked, compare with current time, and the difference will tell you if the double click was quick... This doesn't completely answer your question - you will have to start a delayed timer event to process the single click, and cancel if you think there has been a double click. But this is NOT very Blackberry like. I would suggest using something that is more like the way Blackberry works, like the menu. – Peter Strange Apr 23 '14 at 15:33

0 Answers0