BlackBerryForums.com : Your Number One BlackBerry Community      

»Sponsored Links




Reply
 
LinkBack Thread Tools
  (#1 (permalink)) Old
katalyst23 Offline
Knows Where the Search Button Is
 
Posts: 16
Join Date: Jun 2008
Model: n/a
PIN: N/A
Carrier: n/a
Default Cannot add a ButtonField to a custom manager? - 06-26-2008, 11:04 AM

I came across this problem while writing a custom layout manager for a screen. It works fine with the bitmap, label, and richtext fields that I add, but the moment I add a button field to the manager, it throws an IllegalArgumentException when I call setExtent() in the overriden subLayout() method.

I'm fairly certain it's not something funny in my code - I get the same error when trying to add a button to the manager from the custom manager developer lab.

Has anyone else come across this problem before? Is there some specific way you have to handle button fields when writing a custom layout manager? Does this happen for any of the other fields?
   
Reply With Quote
Sponsored Links
Please Login or Register to Remove these Advertisements!

  (#2 (permalink)) Old
Ivanov Offline
Talking BlackBerry Encyclopedia
 
Posts: 200
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Default 06-27-2008, 10:35 AM

it might help if we see your overriden subLayout() code...
   
Reply With Quote
  (#3 (permalink)) Old
katalyst23 Offline
Knows Where the Search Button Is
 
Posts: 16
Join Date: Jun 2008
Model: n/a
PIN: N/A
Carrier: n/a
Default 06-27-2008, 12:07 PM

Sure, it's just the subLayout() code from the developer lab example on the website though. I was just wondering if anyone else had come across this or if there was something I was missing that wasn't mentioned in the developer docs.

Code:
// Does the diagonal layout.  The extent of this manager becomes the sum of
    // the actual widths by the sum of the actual heights of the controlled
    // fields.
    protected void sublayout(int width, int height)
    {
        int x = 0;
        int y = 0;

        for (int i = 0;  i < getFieldCount();  i++) {
            Field field = getField(i);
            layoutChild( field, width-x, height-y );
            setPositionChild(field, x, y);
            x += field.getWidth();
            y += field.getHeight();
        }
        setExtent(x,y);
    }
   
Reply With Quote
  (#4 (permalink)) Old
Ivanov Offline
Talking BlackBerry Encyclopedia
 
Posts: 200
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Default 06-27-2008, 05:07 PM

have you checked the values of x and y before setExtent throws the exception?
   
Reply With Quote
  (#5 (permalink)) Old
katalyst23 Offline
Knows Where the Search Button Is
 
Posts: 16
Join Date: Jun 2008
Model: n/a
PIN: N/A
Carrier: n/a
Default 06-30-2008, 09:26 AM

Yeah, but that shouldn't matter, it's setting the extent for the whole screen, not the field, that's why it confuses me. Even if you replace x and y with the width and height passed into the sublayout method, or some random values (i.e. 10 and 10), it still throws the exception.
   
Reply With Quote
  (#6 (permalink)) Old
Ivanov Offline
Talking BlackBerry Encyclopedia
 
Posts: 200
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Default 06-30-2008, 09:45 AM

I've just tested that custom_manager from the dev lab and replaced the second field (the one that is not focusable) with a ButtonField. It still works...

Do you override any ButtonField members?

Tested on JDE 4.2.1
   
Reply With Quote
  (#7 (permalink)) Old
katalyst23 Offline
Knows Where the Search Button Is
 
Posts: 16
Join Date: Jun 2008
Model: n/a
PIN: N/A
Carrier: n/a
Default 06-30-2008, 01:04 PM

I don't override any ButtonField members, so it must be something else I'm doing wrong. I replaced the second field with a ButtonField in the custom_manager like you did, and it worked fine, so it must be something else in my code. I will go and take a look at it.. thank you very much for taking the time to let me know it can be done. Now I know it is just something wrong that I was doing.
   
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On






Copyright © 2004-2008 BlackBerryNews.com, BlackBerryFAQ.com, BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of Research In Motion Limited.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.1