How to set focus on the bitmap field, blue is not displayed, blackberry

I am using a bitmap field containing a small image.

When the focus appears in this image, the blue focus color does not appear, how can I set the width and height of the focus

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 how I work with the image field,

although my image is clickable, but I do not see this blue color (I want this to help !!!)

changing width and height values ​​in getFocusRect doesn't even solve the problem

+3
source share
3 answers

, , , . , - .

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

        };
+3

; :

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

Ashraf's suggestion is correct, only I will try to avoid setting a "space" with every call to drawFocus.

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

0
source

Source: https://habr.com/ru/post/1734025/


All Articles