如何突出重点定制ButtonField字段上黑莓(ImageButtonField)? [英] How to highlight focused custom buttonfield (ImageButtonField) on Blackberry?

查看:124
本文介绍了如何突出重点定制ButtonField字段上黑莓(ImageButtonField)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个自定义的类ButtonField字段在那里我有一个形象的按钮。不过,我希望能够选择这个形象,它被选中要知道,无论是部分高亮显示它或将它周围的广场,等等。我有我的UI一个BitmapField,突出自己在蓝色当我选择它,但我使用ImageButtonField其他图像,没有蓝色的亮点。我不想当选择位图就彻底消失了。

I made a custom ButtonField class where I have an image as a button. However, I would like to be able to select this image and to know it is selected, either by partially highlighting it or putting a square around it, whatever. I have a BitmapField in my UI that highlights itself in blue when I select it, but my other images that use ImageButtonField, do not have the blue highlight. I do not want the bitmap to disappear completely when selected.

这里是code:

package mypackage;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.component.BitmapField;

    public class ImageButtonField extends BitmapField{

    public ImageButtonField(Bitmap image) {
        super(image);
    }

    public boolean isFocusable() {
        return true;
    }

    protected boolean navigationClick(int status, int time) {
        fieldChangeNotify(0);
        return true;
    }

    protected boolean trackwheelClick(int status, int time) {
        fieldChangeNotify(0);
        return true;
    }

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

任何修改这一类,所以它的工作将极大地有助于帮助。我有没有成功,努力使这项工作!

Any help modifying this class so it works would help immensely. I have had no success trying to make this work!

推荐答案

要删除默认样式属性,你可以添加下面的方法:

To remove default styling attributes you can add following methods:

protected void applyTheme(Graphics arg0, boolean arg1) {
}

protected void drawFocus(Graphics graphics, boolean on) {
}

您可以覆盖paint方法,做任何你想要检查的重点地位漆,例如以下code将油漆过的位图图像一个红色的透明层。

You can override paint method and do paint whatever you want by checking focus status, e.g. following code will paint a red transparent layer over the bitmap image.

protected void paint(Graphics graphics) {
    super.paint(graphics);
    if (isFocus()) {
        graphics.setGlobalAlpha(128);
        graphics.setColor(0xFF0000);
        graphics.fillRect(0, 0, getWidth(), getHeight());
    }
}

其实我不明白你的问题很好。)

Actually I didn't understand your question well :).

这篇关于如何突出重点定制ButtonField字段上黑莓(ImageButtonField)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆