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
New Developer
bbproductivity
Posts: 24
Registered: ‎05-16-2009
My Device: Not Specified

Triggering ChangedEvent on ChoiceField

Hi,

 

I am running into some problems with a choice field, maybe one of you guys can help me....i am stuck :-( 

 

I have a choice field and when a user selects one of the entries, a menu is shown to select files.  after the user selects a file, the filename is shown in a special field and the choicefield is set to the entry that triggered the file dialog. Currently if the user wants to open the file menu again he has to first deselect the entry in the choice field and then select it again in order for the fieldchanged event to be triggered and the menu to be shown.

 

Is there any way how i can implement this that whenever the user clicks on one certain entry in the choicefield a fieldchanged event is triggered (without selecting another entry in the choicefield).

 

I have tried this already but with no success:                 

 

 

 

ChoiceField test = new ChoiceField() { protected boolean navigationClick(int status, int time) { setDirty(true); return true; } };

 

Thanks for your help,

 

Please use plain text.
Administrator
MSohm
Posts: 14,362
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Triggering ChangedEvent on ChoiceField

The FieldChanged event occurs when the value of the field changes.  You could quickly programmatically change the value of a field and then change it back to trigger a FieldChanged event (this would actually create 2 events).  The dirty flag marks whether the data in the field has been saved or not, it doesn't trigger a FieldChanged event.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: Triggering fieldChanged Event on ButtonField

I am over riding NavigationClick, but even if I return false, the button field with focus does not generate a fieldChanged.  It doesn't seem that the button has a value to change to force the fieldChanged.  Is there a way to force a fieldChanged for a button field that has focus?

 

Thanks!

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Triggering fieldChanged Event on ButtonField

In my experience, a ButtonField will generate a change event when it is clicked.  This is, in fact, I generally do my buttons, especially as it works regardless of whether the Button is displayed on a Touchscreen or Trackball/pad device.

 

If you are not seeing this, try a standard ButtonField, then compare that to your ButtonField.

Please use plain text.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: Triggering fieldChanged Event on ButtonField

Thanks Peter;

 

You are correct it works for a buttonField but not a custom buttonField. 

 

I forgot that my custom button fields extend field not buttonField.  Now I just have to figure out how to trigger the fieldChanged event for a custom field.

 

What I find odd is that when I do not override navigationClick I get the fieldChanged event, but when I override navigation click and just return false, it doesn't.

 

I'm going to keep working on this, but if anyone has any thoughts, they are appreciated.

 

Thanks!

Please use plain text.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: Triggering fieldChanged Event on ButtonField

Got it.

 

I had to set a variable, CurrentButton, and then send that custom button a navigation click


protected boolean navigationClick(int status, int time){
        CurrentButton.navigationClick(status, time);
        return true;
 }

 

Thanks for the help Peter.

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Triggering fieldChanged Event on ButtonField

Here is something I do in another Field, so that I just need to have a ChangeListener for the Field.  Perhaps something similar will work for you.  touchEvent code is 4.7 and above only of course. 

 

    protected boolean navigationClick(int status, int time) {
        this.fieldChangeNotify(2);
        return true;
    }

    protected boolean touchEvent(TouchEvent message) {
        // If click, process Field changed
        if ( message.getEvent() == TouchEvent.CLICK ) {
            this.fieldChangeNotify(2);
            return true;
        }
        return super.touchEvent(message);
    }

Please use plain text.