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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 54
Registered: ‎01-24-2009
My Device: Not Specified
Accepted Solution

CustomButtonField fieldChanged

This page seems to outline what I need to do, just hoping someone can help me with more detail:

http://rim.lithium.com/t5/BlackBerry-App-World-Development/Click-event-on-the-Custom-button/m-p/2943...

 

So I have a CustomButtonField:

        CustomButtonField submitButton = new CustomButtonField("Submit", Color.LIGHTGREY); //65,112,160);
        submitButton.setChangeListener(this);

 

Then, within the same HorizontalFieldManager, I have two standard ButtonFields.

 

I have one fieldChanged function:

 

 

    public void fieldChanged(Field field, int context) {

        if (field == submitButton) {
            submitStart();
        }
        else if (field == testButton) {
            testStart();
        }        
    }

 

If I click my CustomButtonField, the

 

if (field == submitButton) {

is NOT true so it never calls submitStart();

 

If I click on my standard ButtonField, testButton, that if statment is true and it executes testStart() as expected.

 

Seems like the link above suggests I either need to have another fieldChanged function specifically for my CustomButtonField or I need to get the instance.  I'm just not sure exactly how to start on either of these solutions.

 

 

 

Developer
Posts: 467
Registered: ‎07-16-2009
My Device: Z10 LE
My Carrier: Vodafone NL

Re: CustomButtonField fieldChanged

Hi zookie,

 

Are you sure that you field change event method is invoked? Maybe other manager/screen set another change listener?

You said that expression result is FALSE - so you did debug - can you see what filed instance is comming as parameter?

 

Posting of the CustomButtonField code is recommended also.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: CustomButtonField fieldChanged

Can you please confirm that when your submitButton is 'pressed', that your FieldChanged method is invoked.  I presume it is.  In which case, I could absolutely confirm the scope and status of the submitButton Object that you create with:

 

CustomButtonField submitButton = new CustomButtonField("Submit", Color.LIGHTGREY); //65,112,160);


I can't see the code you have supplied us failing unless you have multiple instances of submitButton, add a different button, or update that reference at some other place in your program, perhaps with another

submitButton = new CustomButtonField(...);

 

So put break points on the lines

 

submitButton.setChangeListener(this);

if (field == submitButton) {

and make sure your submitButton reference points to the same object in both places.

New Developer
Posts: 54
Registered: ‎01-24-2009
My Device: Not Specified

Re: CustomButtonField fieldChanged

Good call Peter!  Very silly mistake.

 

Within the class before the main constructor I had defined:

CustomButtonField submitButton;

 

Then, within the constructor I had:

        //add button to submit
        CustomButtonField submitButton = new CustomButtonField("Submit", Color.LIGHTGREY); //65,112,160);
        submitButton.setChangeListener(this);

 

As soon as I changed it so it was:

        //add button to submit
        submitButton = new CustomButtonField("Submit", Color.LIGHTGREY); //65,112,160);
        submitButton.setChangeListener(this);

 

It works great!  Thanks.