Results 1 to 4 of 4
  1. xdeveloper's Avatar
    CrackBerry User

    Posts
    20 Posts
    Global Posts
    21 Global Posts
    Thread AuthorThread Author   #1  

    Default The ListField object and annoying context menu

    Hello,

    Couple days ago I have discovered a strange bug in my app.

    I have two Screen objects:
    - Screen1, which displays the ListField control,
    - Screen2, which displays the data of an item selected through the ListField control.

    Now, when I select an item on the ListField control (on the Screen1) and then press the trackpad, the Screen2 appears, but also a context menu is displayed that belongs to Screen1 (Screen1 and Screen2 objects have different context menus).

    I have tried everything that is known to me to overcome this issue, but... with no success so far.

    The navigation click is handled in the following way (Screen1):

    protected boolean navigationClick(int status, int time)
    {
    Field field = this.getFieldWithFocus();

    if (field instanceof ListField)
    {
    // here I'm getting the element data from the ListField object
    // ...
    Screen2 screen2 = new Screen2();
    UiApplication.getUiApplication().pushScreen(screen 2);

    return true;
    }

    return super.navigationClick(status, time);
    }

    protected boolean navigationUnclick(int status, int time)
    {
    return false;
    }


    The ListField control is initialized as follows (also Screen1):

    lstData = new ListField(0, Field.FIELD_HCENTER);
    lstData.setMargin(2, 2, 2, 2);


    I have no idea what's wrong with this code... I tried to use ButtonField.CONSUME_CLICK style - but this also does not work.

    What's more interesting, this context menu does not appear on the 9800 simulator - at least I was unable to see it on this simulator. But when I'm testing this app on my 9780 device, the context menu appears every time.
  2. pkcable's Avatar

    Posts
    21,164 Posts
    Global Posts
    23,003 Global Posts
    PIN
    PIN:K Floyd!
    #2  

    Default

    Anyone have an answer for my friend here? I'm just getting start myself so I can't be much help, but hopefully some of our experts can answer your question.
  3. xdeveloper's Avatar
    CrackBerry User

    Posts
    20 Posts
    Global Posts
    21 Global Posts
    Thread AuthorThread Author   #3  

    Default

    @pkcable

    Thanks, I hope that someone will be able to help me with this issue.
  4. xdeveloper's Avatar
    CrackBerry User

    Posts
    20 Posts
    Global Posts
    21 Global Posts
    Thread AuthorThread Author   #4  

    Default

    I have finally solved this issue...

    The problem was caused by the Screen1, which was not closed and because of that its context menu was displayed every time, when the Screen2 was displayed.

    After adding the below line, it works fine now:

    protected boolean navigationClick(int status, int time)
    {
    Field field = this.getFieldWithFocus();

    if (field instanceof ListField)
    {
    // here I'm getting the element data from the ListField object
    // ...
    Screen2 screen2 = new Screen2();
    UiApplication.getUiApplication().pushScreen(screen 2);
    this.close();

    return true;
    }

Posting Permissions