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
Developer
Posts: 179
Registered: ‎09-11-2009
My Device: Not Specified
Accepted Solution

Problem With Nested Manager in DialogFieldManager

I'm successfully displaying a PopupScreen with an icon, title, two single line fields and two buttons in the correct places.  I'm doing this by calling the PopupScreen constructor with DialogFieldManager

 

The problem is the fixed height BasicEditField that I'm trying to add.  The space for the BasicEditField is there, but the BasicEditField is not.

 

Here's the code I'm using.  Note:  I've left out the ButtonField and FieldChangeListener code to keep it short.  I've also tried using customManager.add() instead of delegateFieldManager.addCustomField()...neither works:

 

 

     eflink = new EditField("", link);
        efname = new EditField("", "");
        befd = new BasicEditField("", "")
        {
            public int getPreferredHeight()
            {
                return 60;
            }
        };
        dsm = dfm.getCustomManager();
        hfm = new HorizontalFieldManager(Manager.FIELD_HCENTER);
        tvfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL)
        {
            protected void sublayout( int maxWidth, int maxHeight )
            {
                int width = maxWidth;
                int height = maxHeight;
                width = dfm.getWidth();
                height = dfm.getHeight() + befd.getPreferredHeight();
                // super.sublayout( width, height);
                setExtent( width, height);
            }
        };
        dfm.addCustomField(eflink);
        dfm.addCustomField(efname);
        //
        tvfm.add(befd);
        hfm.add(post);
        hfm.add(cancel);
        dfm.addCustomField(tvfm);
        dfm.addCustomField(hfm);
     }

 

Can anyone see what I'm doing wrong?

 

Developer
Posts: 179
Registered: ‎09-11-2009
My Device: Not Specified

Re: Problem With Nested Manager in DialogFieldManager

[ Edited ]

Even more confusing...the layout changes depending on how I place the add(Field f); and addCustomField(Field f) methods.

 

For example, this code lays out the fields entirely wrong:

 

 

        eflink = new EditField("", link);
efname = new EditField("", "");
befd = new EditField("", "")
{
public int getPreferredHeight()
{
return 60;
}
};
hfm = new HorizontalFieldManager(Manager.FIELD_HCENTER);
hfm.add(post);
hfm.add(cancel);
tvfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR)
{
protected void sublayout( int maxWidth, int maxHeight )
{
int width = maxWidth;
int height = maxHeight;
System.out.println("befd pref width: " + befd.getPreferredWidth());
width = dfm.getWidth() + befd.getPreferredWidth();
height = dfm.getHeight() + befd.getPreferredHeight();
super.sublayout(width, height);
setExtent( width, height);
}
};
tvfm.add(befd);

dfm.addCustomField(eflink);
dfm.addCustomField(efname);
dfm.addCustomField(hfm);
dfm.addCustomField(tvfm);

 

Are there any docs on when fields are actually laid out or positioned within Managers?  One specific to DialogFieldManager would be helpful too...

 

 

EDIT: Getting closer.  This code shows the troublesome fixed size EditField, but  pressing enter in the field suddenly displays the vertical scrollbars, increases the size of the screen vertically and moves the two buttons off center

 

 

        hfm = new HorizontalFieldManager(Manager.FIELD_HCENTER);
        tvfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR)
        {
            protected void sublayout( int maxWidth, int maxHeight )
            {
                int width = maxWidth;
                int height = maxHeight;
                System.out.println("befd pref width: " + befd.getPreferredWidth());
                width = dfm.getWidth() + befd.getPreferredWidth();
                height = dfm.getHeight() + befd.getPreferredHeight();
                setPositionChild(befd, 0, 0);
                layoutChild(befd, width, height);
                super.sublayout(width, height);
                setExtent( width, height);
            }
        };
        dfm.addCustomField(eflink);
        dfm.addCustomField(efname);
        tvfm.add(befd);
        dfm.addCustomField(tvfm);
        hfm.add(post);
        hfm.add(cancel);
        dfm.addCustomField(hfm);

 

Feel free to jump in with help, suggestions, advice...

 

Developer
Posts: 179
Registered: ‎09-11-2009
My Device: Not Specified

Re: Problem With Nested Manager in DialogFieldManager

Anyone? 

 

I'm still struggling with this.  I am changing where the add() methods are placed, to see if that helps, and I'm changing which Manager I add the fields to. 

 

From what I've read in the docs there should be two managers for the DialogFieldManager:  the manager itself...which I've obtained by dfm = (DialogFieldManager)getDelegate;... and the custom manager that the DialogFieldManager uses to lay out the custom user fields...which I've obtained by dsm = dfm.getCustomManager();

 

Again, any help is appreciated.

Developer
Posts: 179
Registered: ‎09-11-2009
My Device: Not Specified

Re: Problem With Nested Manager in DialogFieldManager

Solved!

 

I took the code from this doc, removed the EditField reference and added a Field parameter to the constructor.

I then used the resulting custom Manager in place of the VerticalFieldManager in my previous code....using the fixed EditField as the Field arg to the custom Manager constructor.