开发者

Blackberry Event Handling and Focus Issues

I am having an issue with a small blackberry application where touch events are being processed by 1 of 2 certain fields that has focus.

In my case, I have 2 images, one at the top (first element on the screen) and at the bottom (last element added to the screen. Both are subclasses of the BitmapField. Their purpose is to display a web site when the user taps (clicks with the trackpad/ball).

The issue is when either of these has focus, no matter where the user taps on the screen (i.e. in an EditField, another custom button, or just a part of the background), the BitmapField that has focus consumes the event calls the web browser. This obviously only an issue on the BB Torch simulator, and I building for BB OS 5.0.

I have the BitmapField consuming both navigation clicks and touch events.

Also, any direction on where to get a good (as in not written by RIM) event handling guide for the Blackberry API would be helpful.

UPDATE: I have tried:

    public boolean isFocusable() {
        return false;
    }

But, ideally I would like this to work开发者_Go百科 on devices such as the Curve and Bold.

UPDATE 2: There a couple of LabelFields inside layout managers that can receive focus, but they do not cause this issue, it only happens when the BitmapFields have focus.


I'd suggest to create a custom image button field by subclassing from Field. Override paint(Graphics graphics) to draw image and focused border (or background). Then just override navigationClick(int status, int time). The BB UI framework will call that method when user clicks your field on a touch screen. As well it'll work for a non-touch screen devices. As a great benefit - you will not need to bother yourself with TouchEvents at all.


Make sure that on the touchEvent() you are checking the location of the touch. If it is outside of your BitmapField's extent, you should be returning super.touchEvent(message). Regardless of where the touch is, when a field has focus it is sent to it first to determine if it should be handling it at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜