BlackBerryForums.com : Your Number One BlackBerry Community   Wallpaper Megaplex for BlackBerry   

»Sponsored Links



Reply
 
LinkBack Thread Tools
  (#1 (permalink)) Old
treydrake Offline
New Member
 
Posts: 1
Join Date: Feb 2008
Model: 8830
PIN: N/A
Carrier: verizon
Default Trouble with CustomItem and CommandItemListener - 02-11-2008, 07:00 PM

I'm having trouble with CustomItem and CommandItemListener. The 8130 emulator and 8830 handset do not present a "Select" Menu pick when pressing the pointer with the examples below. This only appears to be a problem when extending CustomItem. Attaching a CommandItemListener to a StringItem works as advertised so I must be missing something in the CustomItem though no other interfaces are required by the spec. Also, the supplied code works as advertised with the Sun WSTK and Samsung phones.


Code:
    class FooItem extends CustomItem {
        public final static String FOO = "click me";

        public FooItem() {
            super(null);
        }

        protected int getMinContentWidth() {
            return Font.getDefaultFont().stringWidth(FOO);
        }

        protected int getMinContentHeight() {
            return Font.getDefaultFont().getHeight();
        }

        protected int getPrefContentWidth(int arg0) {
            return getMinContentWidth();
        }

        protected int getPrefContentHeight(int arg0) {
            return getMinContentHeight();
        }

        protected void paint(Graphics g, int arg1, int arg2) {
            g.drawString(FOO, 0, 0, g.TOP | g.LEFT);
        }
    }
The above field is then initialized in the following manner:

Code:
   FooItem f = new FooItem();
   f.setDefaultCommand(new Command("select me", Command.ITEM, 0);
   f.setItemCommandListener(this);
   form.append(f);
I'm stumped. I've added my own event handling to get around the problem (dispatch the listener within the custom item), however, that solution does not present the BB native L&F. Thanks for taking a look.

-t
   
Reply With Quote
Sponsored Links
Please Login or Register to Remove these Advertisements!

  (#2 (permalink)) Old
priyj Offline
New Member
 
Posts: 8
Join Date: Apr 2008
Model: 8700
PIN: N/A
Carrier: Airtel
Default 05-15-2008, 05:41 AM

I have also tried something like this. setDefaultCommand() doesn't seem to come up as a command on BB devices. However, if you simply add a command addCommand(..) to the form that contains the custom item, then it would come up.
   
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




Wallpaper Megaplex for BlackBerry


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