Rupert
Rupert

Reputation: 4613

Blackberry: BitmapField as Buttons

I have a custom Manager BannerObj object with a bitmapfield. I am adding a BannerObj object to the screen. I want to make the bitmapfield of the BannerObj clickable so that it opens up a url in browser.

I have tried overriding the invokeAction methods of both bitmapfield and BannerObj but Im not able to click the image nor select it.

Upvotes: 0

Views: 562

Answers (1)

Vivart
Vivart

Reputation: 15313

try this

BitmapField  custombitmapField = new BitmapField(bitmap,Field.FOCUSABLE){
            protected boolean navigationClick(int status, int time) {
                openBrowser();
                return true;

            }

            protected boolean keyChar(char character, int status, int time) {
                if (character == Characters.ENTER) {
                    openBrowser();
                    return true;
                }
                return super.keyChar(character, status, time);

            }
            void openBrowser(){
                BrowserSession browserSession = Browser.getDefaultSession();
                browserSession.displayPage(url);
                browserSession.showBrowser();
            }
        };

Upvotes: 2

Related Questions