Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 69
Registered: ‎07-18-2011
My Device: 9630 Tour
My Carrier: Verizon
Accepted Solution

MenuItem and Consume click

is there a way to consume a click from a menu item?

 

I am using ListField to display records which can be edited by clicking on a particular record, which displays an edit form. The problem occurs  when I want to pull fresh data from a webservice and re-display the ListField, the user clicks on a menu item which initiates the fetch from a webservice, but the click event triggers the edit form, which is not what I want.

 

So I'd like to know if there's a way to consume a click from a menu item?

 

Thanks,

Steve

Developer
Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: MenuItem and Consume click

i don't understand your issue, you have full control over the actions of your menu item, you can just do nothing if it was clicked.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 69
Registered: ‎07-18-2011
My Device: 9630 Tour
My Carrier: Verizon

Re: MenuItem and Consume click

the menu item basically calls a function that fetches new data via https, that will be filtered differently or sorted differently; so I need the user to click on the menu item to call the function, but I also need to kill the click event so that it doesnt call navigationClick() in ListField.

 

Steve

Developer
Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: MenuItem and Consume click

a click on a system menu is not propagated to a field below.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 69
Registered: ‎07-18-2011
My Device: 9630 Tour
My Carrier: Verizon

Re: MenuItem and Consume click

Here's some code snippets to give you an idea as to what I am trying to do:

 

 private MenuItem _filterByPriority = new MenuItem("Filter By Priority", 100, 3)
    {
       
        public void run()
        {
           
            customObjListField.refresh(tableRows); // fetch new data via https and refresh the custom ListField.
        }
    };

 

 

 

After the menu item is clicked it calls the refresh function, but it also calls navigationClick() and fieldChanged() in the custom list field:

 

 

Here's where I instantiate  my custom list field:

 

         customObjListField = new CustomObjectListField(rows, employeeId){               
                protected boolean navigationClick(int status, int time) {
                     fieldChangeNotify(0);
                     return true;
                }
               
                protected boolean keyChar(char character, int status, int time) { 
                    if (character == Characters.ENTER) {
                        fieldChangeNotify(0);
                        return true; 
                    } 
                    return super.keyChar(character, status, time); 
                } 
            };

 

 

 

Here's the fieldChanged() function that displays the edit screen:

 

 

    public void fieldChanged(Field field, int context) {

        if(   field.equals(customObjListField) ){           
            int selectedIndex = customObjListField.getSelectedIndex() ;
            UiApplication.getUiApplication().pushScreen( new editUser((Hashtable)tableRows.elementAt(selectedIndex)));
        }       

    } 

 

Thanks,

Steve

Regular Contributor
Posts: 69
Registered: ‎07-18-2011
My Device: 9630 Tour
My Carrier: Verizon

Re: MenuItem and Consume click

[ Edited ]

I was able to resolve this by killing the FieldChangerLister and then re-enabling it after the menu click...here's the code:

 

  private MenuItem _filterByPriority = new MenuItem("By Priority", 100, 3)
    {
       
        public void run()
        {           
            FieldChangeListener fcl = customObjListField.getChangeListener();
            customObjListField.setChangeListener(null);
            customObjListField.refresh(tableRows);
            customObjListField.setChangeListener(fcl);
        }
    };

 

 

Thanks Simon for putting me on the right track,

Steve