如何将焦点设置在位图字段上,蓝色不可见,黑莓

发布于 2024-08-22 12:48:49 字数 728 浏览 10 评论 0原文

我正在使用包含小图像的位图字段。

当焦点位于该图像上时,不会出现焦点的蓝色,我如何设置焦点宽度和高度

我的代码::

contract_image_field = new BitmapField(contract_image,Field.FOCUSABLE)
 {
       public void getFocusRect(XYRect rect) 
      {
       rect.width=0;
       rect.height=0;
       //super.getFocusRect(rect);
      }
       protected void onFocus(int direction) 
       {
        myScreen.this.invalidate();
      super.onFocus(direction);
     }
       protected void onUnfocus() 
       {
        myScreen.this.invalidate();
      super.onUnfocus();
     }
      };
      contract_image_field.setBitmap(contract_image);

这是我使用图像字段的方式,

虽然我的图像是可点击的,但我看不到蓝色(我想要,请帮忙!!!)

改变 getFocusRect 中的宽度和高度值甚至不能解决问题

i am using a bitmap field that contains a small image.

when focus comes on that image then blue color of the focus does not appears,how can i set the focus width and height

my code::

contract_image_field = new BitmapField(contract_image,Field.FOCUSABLE)
 {
       public void getFocusRect(XYRect rect) 
      {
       rect.width=0;
       rect.height=0;
       //super.getFocusRect(rect);
      }
       protected void onFocus(int direction) 
       {
        myScreen.this.invalidate();
      super.onFocus(direction);
     }
       protected void onUnfocus() 
       {
        myScreen.this.invalidate();
      super.onUnfocus();
     }
      };
      contract_image_field.setBitmap(contract_image);

this is the way how i work with image field,

though my image is clickable but i cant see that blue color(i want that please help!!!)

changing values of width and height in getFocusRect does not even solves the problem

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

断桥再见 2024-08-29 12:48:49

您还可以避免增加场地范围;
使用以下代码:

BitmapField bitmapField = new BitmapField(bitmap, BitmapField.FOCUSABLE)
{
     protected void drawFocus(Graphics graphics, boolean on) 
     {
          setSpace(5, 5);
          super.drawFocus(graphics, on);
     }       
};

You can also avoid increasing the field extent;
using the following code:

BitmapField bitmapField = new BitmapField(bitmap, BitmapField.FOCUSABLE)
{
     protected void drawFocus(Graphics graphics, boolean on) 
     {
          setSpace(5, 5);
          super.drawFocus(graphics, on);
     }       
};
半岛未凉 2024-08-29 12:48:49

实际上焦点就在那里,但你看不到,因为焦点区域与场的整个范围相同。如果你想看到焦点矩形,请增加视野范围。

BitmapField  bitmapField = new BitmapField(bitmap,Field.FOCUSABLE){
            protected void layout(int width, int height) {
                setExtent(bitmap.getWidth()+10, bitmap.getHeight()+10);
            }

        };

actually focus is there but you can't see because focus region is the same as the field's entire extent. if you want to see focus rect increase the field extent.

BitmapField  bitmapField = new BitmapField(bitmap,Field.FOCUSABLE){
            protected void layout(int width, int height) {
                setExtent(bitmap.getWidth()+10, bitmap.getHeight()+10);
            }

        };
如梦亦如幻 2024-08-29 12:48:49

阿什拉夫的建议是正确的,只是我会尽量避免在每次绘制焦点调用时设置“空间”。

只需调用 setSpace(int, int) 成员在相关的 bitmapField 上一次。

Ashraf's suggestion is correct, only I would try to avoid setting the 'space' on every drawFocus call.

just call setSpace(int, int) member once on the bitmapField in question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文