user528097
user528097

Reputation: 1

BlackBerry Bitmap listener

I have a code similar to the one below, painting over the mapfields this mIcon several times. How can I add a click listener to this bitmap ? I am using bb 5.0

public Bitmap mIcon;
mIcon = Bitmap.getBitmapResource("pcture1.png");

protected void paint(Graphics g) {


 super.paint(g);
        mDest = new XYRect(....);
        g.drawBitmap(mDest, mIcon, 0, 0);
}

Upvotes: 0

Views: 833

Answers (1)

Jonathan
Jonathan

Reputation: 1731

Override BitmapField and modify the isFocusable(), navigationClick(), keyChar(), and trackwheelClick() methods.

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);
   }

}

Upvotes: 2

Related Questions