Image Map-like Blackberry Control - CLDC Application

巧了我就是萌 提交于 2019-12-23 23:05:38

问题


Does anyone know of an Image Map-like Blackberry Control that I can use in my CLDC application? If there isn't one, is there a way to get click x,y coordinates on a MainScreen or BitmapField derived control?

Thanks,


回答1:


I assume you're thinking of this control for the Storm - the only device for which clicking on an arbitrary point on screen makes sense.

In that case, the easiest way is probably to subclass BitmapField to be focusable and respond to clicks - something like this:

public class ClickableBitmapField extends BitmapField {
// Make the control focusable    
public boolean isFocusable() {
       return true; 
}

protected boolean touchEvent(TouchEvent message) {
    if (message.getEventCode == TouchEvent.CLICK) {
        int x = message.getX();
        int y = message.getY();
        // do something with x and y here
    }
}
}

Of course it'd be a lot more complicated to implement image map type functionality for a trackball device - you'd have to maintain a cursor or something so the user knows where they're clicking.



来源:https://stackoverflow.com/questions/782661/image-map-like-blackberry-control-cldc-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!