BitmapField consumes all clicks on the screen

Hello

I hope someone can help me with this problem: I have a screen that has only BitmapField is on. When you click on this 'something' BitmapField should be here which works very well.

The problem is that even if I click elsewhere on the screen the 'click' fires.

This is the main code on the screen:

VerticalFieldManager view = new VerticalFieldManager();

Bitmap bm = Bitmap.getBitmapResource("image.jpg"); // size 60x60
MyBitmapField bmf = new MyBitmapField(bm, BitmapField.FOCUSABLE);
bmf.setChangeListener(this);
view.add(bmf);
add(view);

And that the implementation of the 'MyBitmapField ':

public class MyBitmapField extends BitmapField
{
  public MyBitmapField(Bitmap bitmap)
  {
    super(bitmap);
  }

  public MyBitmapField(Bitmap bitmap, long style)
  {
    super(bitmap, style);
  }

  protected boolean navigationClick(int status, int time)
  {
    FieldChangeListener listener = getChangeListener();
    if (null != listener)
    {
      Dialog.alert("Clicked");
      listener.fieldChanged(this, 1);
      return true;
    }

    return super.navigationClick(status, time);
  }

  protected boolean touchEvent(TouchEvent message)
  {
    /*
    if (TouchEvent.CLICK == message.getEvent())
    {
      int index = this.getManager().getFieldAtLocation(message.getX(1), message.getY(1));
      if (index == -1)
          return super.touchEvent(message);
      Field field = this.getManager().getField(index);
      if (field != this)
        return super.touchEvent(message);

      FieldChangeListener listener = getChangeListener();
      if (null != listener)
        listener.fieldChanged(this, 1);
    }*/
    return super.touchEvent(message);
}

}

In the touchEvent method is a point that I also tried - but that didn't work either.

The fieldChanged Manager is as usual:

  public void fieldChanged(Field field, int arg)
  {
    if (field instanceof MyBitmapField)
    {
      MyBitmapField bmf = (MyBitmapField) field;
      Dialog.alert("Clicked: " + Integer.toString(arg));
    }
  }

I'm actually on the 9550 Simulator.

Can someone please help me and tell me what I need to do to avoid that the click event is fired even if I click outside the BitmapField (I also put a border, just to make it visible, it is not expanded).

Thank you very much

That's exactly how BlackBerry works, even if it is IMHO pretty buggy: the key CLICK event is translated into navigationClick() in the field that currently has the focus. The problem lies in the fact that EVENT moves the focus to the field under him that if there is an active field where you press the screen, otherwise the focus remains where it is.

To overcome this obstacle, program your touchEvent similar to this:

protected boolean touchEvent(TouchEvent message) {
  if (TouchEvent.CLICK == message.getEvent()) {
    int x = message.getX(1);
    int y = message.getY(1);
    XYRect myExtent;
    getExtent(myExtent);
    myExtent.translate(0, 0); // getX, getY values are relative to this field's upper-left corner
    if (!myExtent.contains(x, y)) {
      return true;
    }
  }
  return super.touchEvent(message);
}

You can allow a 'near miss' avoid the frustration of users - extend the myExtent in any quantity you want of each side.

Tags: BlackBerry Developers

Similar Questions

  • No matter what page I click on the screen automatically scrolls to the bottom of the screen

    original title: any page I click on the screen automatically scrolls to the bottom of the screen so THST I'm unable to read whats above. I suspect a recent windows update caused this problem

    See above

    Hi centerZQ of windows media.

    Since it is a recent issue, use System Restore to restore your computer to a point before the issue. This allows you to uninstall the updates or programs that you installed after the date you have selected, then make sure you have a way to reinstall all the programs, if necessary.

    Then, check the updates on your computer. If you have several updates to install, install them in small groups, until the problem reoccur. Once you have identified the update at the origin of the problem, post in the forum.

  • Equium A100-147: minimize windows whenever I click on the screen

    Whenever I click on the screen (for example, scroll up/down buttons, close x) windows on my screen constantly minimize

    Hello

    Do you mean the window of Internet Explorer?

    I think you behavior is linked to the corrupted registry entries.
    You know it is not very easy to fix the registry keys.

    You try to roll back the drunks at the start point or you try to simply reinstall IE and check if the new facility will help.

  • Everything on my screen has tripled in size how it back to the normal size, ps I tried the right hand winder on cone and it just reduces the font size not all things on the screen itself

    Everything on my screen has tripled in size how it back to the normal size, ps I tried the right hand winder on cone and it just reduces the font size not all things on the screen itself

    Your lowered obtained resolution. This can occur if you are running an older game that uses 800 x 600 for example.

    Control Panel > display > settings - change the resolution to correct for your monitor. MS - MVP - Elephant Boy computers - don't panic!

  • My vista computer hangs when I right click on the screen and scroll again.

    My vista computer hangs when I right click on the screen and scroll again.  I guess it's a problem with the windows Explorer.  I ran virus and malware scan and also led the sfc.  I always get the same result.  If anyone has faced this problem and knows the Fox please help

    It could be a problem with the shell extensions.
    Check out these links to see if they might be able to help:

    Make a right-click is slow or weird behavior caused by context menus managers

    and

    ShellExView - Shell Extension Manager for Windows

  • Problem of Timer and TimerTask for counter display all seconds on the screen.

    Dear friends,

    I have little problem in the use of the timer. I took the timer to display the counter on each period fix repeatedly. but I did not here. Please help me. The code is as shown below.

    import java.util.Timer.

    java.util.TimerTask to import;

    Import net.rim.device.api.ui.Field;

    Import net.rim.device.api.ui.UiApplication;

    Import net.rim.device.api.ui.component.RichTextField;

    Import net.rim.device.api.ui.container.MainScreen;

    SerializableAttribute public class TimerTest extends UiApplication

    {

    Timer;

    public static int COUNT = 0;

    Public Shared Sub main (String [] args) {}

    TimerTest tt = new TimerTest();

    tt.enterEventDispatcher ();

    }

    public TimerTest()

    {

    a new screen

    pushScreen (new TimerMainScreen());

    }

    SerializableAttribute public class TimerMainScreen extends screen

    {

    TimerMainScreen()

    {

    Add (new RichTextField ("Count =" + Integer.toString (COUNT), Field.NON_FOCUSABLE));

    try {}

    Timer = new Timer();

    timer.scheduleAtFixedRate (new TimerMainEvent (), 200, 1000);

    }

    catch (System.Exception e)

    {

    do nothing

    }

    }

    private class TimerMainEvent extends TimerTask

    {

    public void run()

    {

    Try

    {

    COUNT ++;

    If (COUNTY<>

    Add (new RichTextField ("Count =" + Integer.toString (COUNT), Field.NON_FOCUSABLE));

    on the other

    Timer.Cancel ();

    Timer.Cancel ();

    }

    catch (System.Exception e)

    {

    Do nothing

    }

    }

    }

    }

    }

    Please let me know where I'm wrong, I want to display all seconds on the screen. If I set the interval 0 then it run TimerMainScreen first time but after all no update, I see on the screen.

    I thank in advance

    Vimal

    Use the following Code in your race.

     UiApplication.getUiApplication().invokeLater(new Runnable()
     {
      public void run()
      {
       add(new RichTextField("Count = " + Integer.toString(COUNT)   ,Field.NON_FOCUSABLE));
      }
     });
    
  • Problem when creating objects to the point user clicks on the screen

    I'll sometimes have a problem when clicking on the screen and have an object at this time created. 95% of the time it works properly, but sometimes, the object is created in a different area of the screen.

    Everyone comes across something similar? Or is it likely to be just a problem with the Simulator?

    Thank you very much for any help offered.

    If you want a "newLabel" to appear in the contact details of your mouseEvent, but only if details of mouseEvent are lower on the screen (having a higher value) at the height of your textButton.

    If your TextButton object does not touch the top of the stage (y = 0), you'll want to write this instead:

    if (event.localY > textButton.y + textButton.height)
    

    It may be a good idea to write it anyway, just in case you want to change the position of the TextButton.

    In addition, localX and localY properties of your mouseEvent are compared to the event containing sprite.  for example, if you have a canvas Sprite that is a parent of your textButton and is tuned for the mouseEvent.  otherwise, if there is no sprite contains (second phase) for your event, you'll want to use stageX and stageY instead.

    I guess since I can't be sure of your intentions here, but try this instead:

    private function createItem(event:MouseEvent):void
         {
         if (event.stageY > textButton.y + textButton.height)
            {
            var newLabel:TextField = new TextField();
            newLabel.x = event.stageX;
            newLabel.y = event.stageY;
            newLabel.text = "test";
            newLabel.setTextFormat(userTextFormat);
    
            addChild(newLabel);
            }
         }
    
  • How to get rid of spinning blue circle that appears when I click on the screen icon

    When I move the cursor on the scoreboard at the bottom of the screen, arrow disappears and spinning blue circle appears. When I move the slider arrow icon on the display, the arrow disappears and blue circle appears, but it also no longer allows me to click on an icon or open any folder.

    I can not also open taskbar to see what programs might be running that shouldn't be.

    The problem that I now had 12 hours. Happened after PC off after the installation of windows updates (but of course I do not see what were these updates, because I can't open the files!

    can you help me?

    see you soon

    Hello Kostas2005,

    Your system seems to be something to load all the time after an update.

    You can run a system restore to remove updates that are causing problems.

    This will bring the system back to when everything worked correctly without affecting your personal files.

    Here is a link on how to do a restore.

    By clicking on the White Star congratulations on the left is a way of saying thanks!

    I would like to know how everything goes.

    Nice day.

    .

  • In Captivate 7, check-in demo mode captures all changes to the screen, even if I move very slowly.

    For example, I am capturing, accessing an application, by clicking on "agree to terms", then go to the home page. Replay of the record only shows the connection and the homepage, the provisional terms page is not respected. Any ideas?

    It is a common problem.  Captivate is not necessarily 'hear' all the events of the screen in some applications.  Be careful to do this when capture and use manual key entry when you notice that something has not been saved.

  • Do all click on the required boxes before moving on to the next slide

    I created a screen with three areas of click and the next button. The learner will need to click on all three before click boxes he can click next to move to the next slide. If they do not click on all three boxes, that they must get a message saying: they need to view all content before continuing. Does anyone know how to program the next button to require the three click on boxes to be clicked before proceeding?

    Thanks in advance,

    ~ A

    Issue has been addressed several times in this forum. You don't need to program the next button, but click areas. I guess they don't have to be clicked in order? In this case:

    1. create three user, for each box click variables: v_one, v_two, v_three and give them a default value 0
    2. hide the next button (in the Properties Panel - since I don't know the version, wrong in detail)
    3. for each button click on create an advanced conditional action with two decisions:
      • First decision is a standard simulated action "always."
        IF 1 is equal to 1
        Assign the v_one with 1 (change of variable in the actions for the other boxes two click v_two, v_three)
      • Second decision checks the value of these three variables
        IF v_one is equal to 1 AND
        v_two is equal to 1 AND

    v_three is equal to 1

    See the Bt_Next

    Be sure to have the suspension of the next key point later that the point of putting paused click boxes. This means that we need to shorten the timeline of the boxes to click and check the properties of the button sync

    Lilybiri

  • Holding the drawing rectangle left click on the screen - what is it?

    On my desk and some Web pages, I can press the left mouse button, drag it, and he draws a rectangle - as it is to select a field. Release the mouse button the rectangle disappeared and wondering what it was all about. The area inside the rectangle is not highlighted in some way. However, when there is a picture (photo) on the page, SOMETIMES (without moving the mouse), the left click highlights the image in blue degraded even if the pointer is not on the image. It's like a painting - where the rectangle selects an area to be edited, only this doesn't give any options or menus to consider after the rectangle has been established - and then disappears with the release of the button. What is c?

    Hello

    This design, and you don't have to worry about this. It's normal.

    When we have a left-click on the desktop or any empty space (white) away from all the folders and drag it will show you a rectangle, also an area shaded inside the rectangle will appear.

    The function of left click drag is to select so it continue to look the same.

    It will be useful.

  • Click on the screen blackBerry Smartphones PRIV

    I just got a new unlocked AT & T PRIVATE today on Amazon, and the screen makes a rattling noise when they are hit.  On the web, there are a lot of people reporting a similar issue, suggesting turn the phone to try to fix it.  This has not worked for me.

    Is it just a matter of getting a bad or a phone that has not been produced recently? Or PRIVs all will have this problem, even if they are not immediately, because of poor design or manufacturing?

    Hello

    Not all PRIVATE have this problem, but there is no way to predict the outcome for you. Your best bet is to contact free support of PRIVATE formal BB:

    Good luck!

  • Consume a click AND the alignment of the centre

    Goodday,

    I am trying to center align a ButtonField.  When I include the code

    ButtonField btn = new ButtonField("Log In", ButtonField.FIELD_HCENTER);
    

    the button aligns with success on the middle of the screen.

    However, when I click the button, the popup menu will appear.

    In order to get rid of it, I have to write.

    ButtonField btn = new ButtonField("Log In", ButtonField.CONSUME_CLICK);
    

    I tried to have both, but I can't achieve this goal.

    How can I do to fix this problem?

    Any help would be greatly appreciated.

    These are values of bit - it takes 'GOLD' these together:

    ButtonField btn = new ButtonField ("Log In", ButtonField.CONSUME_CLICK |) ButtonField.H_CENTER);

  • Wait that click minimized the screen brightness

    How to use click box?  I guess I wanted to ' pause project until user clicks on ', but if I stop, reduces the brightness of the screen.  How can I prevent the screen from dimming and wait for click?  IF I do not select this option, it does not expect and goes to the next screen.  (I know - basic - but I'm a newbie - please forgive me)

    Hello

    Click the box object is a pause at the end of the time period. If you want to make a break earlier, set the end of the click occurs earlier on the slide area.

    Click on the image below for a larger and more detailed view.

    See you soon... Rick

    Useful and practical links

    Begin to learn Captivate 5 times now! $29.95

    Captivate wish form/Bug report form

    Certified Adobe Captivate training

    SorcererStone blog

    Captivate eBooks

  • When I try to create a shortcut on my desktop for hotmail and I right click on the screen my options do not give me a selection of shortcut.

    I plan to go back to 7 due to problems of this kind.

    That's what I was wondering. What happened when you right-click on the desktop.

    FYI, there is another option. Place the mouse on the icon in front of the address and drag it to the taskbar.

Maybe you are looking for