BitmapField on the touch screen problem

Hello

I have a simple form with two fields of bitmap and I want to take the events of button CLICK on each field. But the problem is that my program behaves like I always click on the first button even if I click on the other.

How can I solve this, what someone has any ideas?

The code is below. Thank you...

public final class TouchEventInjectorScreen extends MainScreen {
    private LabelField labelField;
    private BitmapField button1;
    private BitmapField button2;

    public TouchEventInjectorScreen() {

        setTitle("Touch Demo");

        labelField = new LabelField("");
        add(labelField);
        button1 = new BitmapField(Bitmap.getBitmapResource("1.png"),BitmapField.FOCUSABLE){
            protected void onFocus(int direction) {

                super.onFocus(direction);
            }
            protected boolean touchEvent(TouchEvent message) {
                if(message.getEvent() == TouchEvent.CLICK){

                    System.out.println("1");
                }
                return true;
            }
        };
        button2 = new BitmapField(Bitmap.getBitmapResource("2.png"),BitmapField.FOCUSABLE){
            protected void onFocus(int direction) {

                super.onFocus(direction);
            }

            protected boolean touchEvent(TouchEvent message) {
                if(message.getEvent() == TouchEvent.CLICK){

                    System.out.println("2");
                }
                return true;
            }
        };
        HorizontalFieldManager h1 = new HorizontalFieldManager();
        h1.add(button1);
        add(h1);
        add(new LabelField(""));
        HorizontalFieldManager h2 = new HorizontalFieldManager();
        h2.add(button2);
        add(h2);

    }

}

When I shot the screen always 1 is printed in the system.out

If you try to manage the events button on the two fields that have defined the style as focusable, then there are two ways to handle them.

1. management of the key by its parent event. Is to say, add 2 focusable components Manager then manage the key event in the Manager himself. Here is the code snippet

class MyManager extends VerticalFieldManager
{
protected boolean touchEvent (TouchEvent message)
{
switch (message.getEvent ())
{
case TouchEvent.CLICK:
int x = message.getX (1);
int y = message.getY (1);
int index = getFieldAtLocation (x, y);
Field field = getField (index);
System.out.println ("field->" + index);
field.setFocus ();
break;
}
Returns true;
}
}

class touch screen extends screen
{
Private button1 As BitmapField;
private BitmapField button2;

public TouchScreen()
{
Button1 = new BitmapField (Bitmap.getBitmapResource ("1.png"), BitmapField.FOCUSABLE);
Button2 = new BitmapField (Bitmap.getBitmapResource ("2.png"), BitmapField.FOCUSABLE);
Manager of MyManager = new MyManager();
Manager.Add (button1);
Manager.Add (button2);
Add (Director);
}
}

2. This step is to manage the key event at the level of the component itself. In this case, you must first make sure that this place where we clicked on belongs to the targeted component. because the targeted component key event will be called first by default. This is possible by getting the x, the position and the region where we clicked and check if it is located in the region of this element, otherwise returns false, the event goes to the next component. If the x position is located in the region of a component, handle touch event in this case.

Here is the code snippet

class MyBitmapField extends BitmapField
{
protected boolean touchEvent (TouchEvent message)
{
switch (message.getEvent ())
{
case TouchEvent.CLICK:
If (message.getY (1))<>
Returns false;
If (message.getY (1) > getHeight())
Returns false;
If (message.getX (1))<>
Returns false;
If (message.getX (1) > getWidth())
Returns false;

you code here
break;
}
Returns true;
}
}

Tags: BlackBerry Developers

Similar Questions

  • Problems with the touch screen of HP all-in-One after upgrading Windows

    I recently updated my version of Windows (64-bit) with system updates and then a full version updated to version 8.0 version 8.1.  After the update is complete, I started to experience a strange problem with the touch screen on my HP Envy Rove.  The screen would flash repeatedly one set of points in the right lower quadrant of the screen as if the simulation random screen button.  There is no way to stop this.  If the screen on a keyboard was pulled up, letters in the place of the flashes would be broadcast in the fields on the screen.

    The only way to stop the flashes of screen has been to go into the Device Manager and disable the HID-Compliant device driver.  It stopped (system generated keys) flashes, but also disabled my touch screen input.  So now the system is usable, but without the benefit of the touchscreen.

    Here is the information on the driver:

    HID-Compliant device

    Date: 21/06/2006

    Version: 6.2.9200.16851

    (input.inf)

    I tried updating the driver, but this seems to be the latest version available.  Go back to the previous version of the driver, could solve the problem, but I could not locate on the support web site.

    Any suggestions on how to solve this problem and re-enable the ability of my touch screen?

    Hello

    Downloaded drivers from the manufacturer will be the most tested and up to date available. The best place to download a driver is directly from the manufacturer of the equipment.

    So I suggest you to install the driver that is available on the HP website for your model.

    Troubleshooting of touch screen in Windows 8

    http://h10025.www1.HP.com/ewfrf/wc/document?cc=us&LC=en&DLC=en&docName=c03488148

    Just reply with the results.

  • Can I turn off the TOUCH screen feature?

    Here's my problem: my granddaughter for baby love watching YouTube nursery rhymes on my iPhone before the NAP. But sometimes it naturally touches the screen, which stops the video.

    Is there a way to disable the TOUCH screen of the iPhone function while keeping the video running?

    Thank you!!!

    Hi, Edward

    Yes - you can see that guided access (for example: "Ignore all keys") meets your needs:

    http://help.Apple.com/iPhone/9/#/iph7fad0d10

  • How to temporarily disable the touch screen in Windows 8? TouchSmart 320-1122la

    TouchSmart 320-1122la

    64 bit of Windows 8

    This solution does not work for me because I don't have the option "Use your finger as input device."

    Go to the sounds and then hardware and Control Panel.

    Select the Pen and Touch and go to the contact tab.

    At the top is "Use your finger as input device."  Uncheck the box.

    Click apply and then click OK.

    Is there another solution?

    Thanks in advance.

    Hi, I have a HP TouchSmart 320-1030, so it can work on your TouchSmart:

    1. Press Windows + X logo.
    2. Select Device Manager from the list.
    3. Click on the small arrow next to Interface devices to expand the list.
    4. Click the touchscreen driver (in my case, Voltron NextWindow touch screen).
    5. Right click and select disable from the list.
    6. Click Yes in the dialog box that asks you if you are sure you want to disable the touch screen driver.

    When you want your touchscreen to work again, follow the above procedure, EXCEPT when right-clicking on the touch screen driver, select enable.

    ~ Lil Liebe

    I'm not an employee of HP; I just want to help.

    Click the White Star of Kudos to say thank you *.

    By clicking 'Accept as Solution' on an answer that solves your problem makes it easier for others to find solutions.

  • monitor 23tm: where can I buy a usb cable for the touch screen of hp 23tm?

    This USB cable allows to use the touch screen functions. Anyone know where I can buy a replacement?

    @oneextremehiker, welcome to the forum.

    You should do HP Partsurfer one test to see that HP is available.

    Please click on the button + Thumbs up if I helped you and click on accept as Solution If your problem is resolved.

  • AT300 - area on the touch screen, pick up ghost keys

    Hi people,

    I'm having a problem with my Tablet AT300 where it that takes the touchscreen touches - many of them - in a place where it is not to be touched. When I turn it on, it starts to go crazy with the vibrations repeated thought to touch screen that is to be touched. I see the behavior that it is picking up in an area of the screen - the left-hand side from the bottom when held in orientation landscape with the camera at the top. I can say that it's in this area because it retains hit the back button, and if I do then rotate the device to the left, it keeps bring up the pop-up menu settings of the lower right and close it again.

    I saw one report of this type of behavior that was caused by a loose wire to drop the device. My Tablet has fallen a few times, but not on hard surfaces. It is possible, but it could also be something else. I am reluctant to remove if it's a software problem (well the fact that it is an area of the touch screen suggests it's material, I guess). I guess I could reset it hard, but to be honest, I don't want to do this because my daughter won't lose its apps and saved games.

    So, who is the most likely scenario here, and what is the best way of difficulty? Any help would be greatly appreciated.

    -Larry

    I found interesting instructions on Youtube:

    Search for:
    Toshiba Thrive for the screen replacement repair Guide

  • Portege M750/10J - touch screen problem

    All,

    I have the Tablet above and the touch screen works intermittently,

    The used stylus is that magnetic with the right click feature

    Someone at - it met similar problems?

    Kind regards

    Have you installed the latest version of the BIOS?

    If the latest BIOS does not help, there may be a loose connection, or the system needs an update. An ASP can do for you.

  • HP ENVY 15-ae178ca laptop: I disabled the touch screen on my laptop HP ENVY how I get it back?

    I have disabled my touch screen, how do I get it back on?

    @scoop58

    Welcome to the Forums of HP,
    I hope you're well

    I understand that the touch screen no longer works after upgrade to windows 10,
    don't worry, however, as I have a few steps that should solve your problem:

    To activate the touch screen driver in Device Manager:

    1. In Windows, locate and open the Device Manager.
    2. Expand the Human Interface Devices section.
    3. The touchscreen device is labeled HID-compliant screen touch, or similar. Right click on the touch screen device.
    4. If the option to activate the device is included in the menu, click Activate.

    Keep me posted,

    Kind regards

  • PRS - T1 crashing, freezing and touch screen problems

    I get a LOT of crashes and freezes using the PRS - T1. Sometimes the embedded player software wants to close, at other times, the touch screen is going to die, and I then have to do a reset. Yes, I fully charged the unit before using it. It is VERY annoying. The drive crashed probably 10 times in the last 2 days.

    Mine was too much. I bought it at Best Buy. When he started to act up, I contacted Sony & was told to return it to the store I did. But the replacement does the same thing. After contacting Sony again, I'm now supposed to get a new directly from Sony. He was supposed to be here today, but will probably happen tomorrow for sure. Hope this works very well because I really like the player.

    The problem is that it works very well for 40 minutes then begins to turn the pages quickly & then freezes. It can happen just read or use the dictionary. Also I had trouble fall Sony Reader Store since my T1. Once the problem starts it freezes more & more frequently.

  • How is - this hard I can reset my iPhone 5 with the broken home button and the touch screen is not responding.

    My iPhone 5, iOS 9.0.2 does not respond to touch. (broken touchscreen) and my home button is broken. my battery is fully charged so that it would take too long to wait until it turns off. I need a way to Hard reset it without a button at home and the touch screen. I know there are 3rd party apps that could do this, but I can't open my phone (no password protection) to 'trust' on this computer. If there are applications that could work around this? Any help is appreciated.

    There is no way to do it. You have 2 hardware problems. Time to replace the phone.

  • Help! Disable the touch screen on Envy Touchsmart Ultrabook 4

    Hi, I have a problem, try to disable the touch screen of the Envy Touchsmart Ultrabook 4 function in Windows 8... I was looking for an answer on how to do it, but I did not find anything. I tried the method of the control panel > hardware and sound > pen and touch and then disable the option "use your finger as input device", but this option is not there for me! If anyone knows how to do this, I would be very grateful.

    Hello

    I have another type of TouchSmart, but this may work for you:

    1. Press Windows + X logo.
    2. Select Device Manager from the list.
    3. Click on the small arrow next to Interface devices to expand the list.
    4. Click the touchscreen driver (in my case, Voltron NextWindow touch screen).
    5. Right click and select disable from the list.
    6. Click Yes in the dialog box that asks you if you are sure you want to disable the touch screen driver.

    When you want your touchscreen to work again, follow the above procedure, EXCEPT when right-clicking on the touch screen driver, select enable.

  • Help with the touch screen!

    Hello, I hope someone could help me.  I just installed Windows 8 Professional on my TouchSmart 520-1070, and now the touchscreen does not work. I tried updating the driver, but that didn't work. I'm not computer savvy, but it does not work?

    How can I solve this problem? If anyone from HP is there, please help! Heck, if someone knows the answer, please help!

    OK... no one answered, but I guess it's ok because I've solved the problem.  You must make the updates for the office and add the extras. It is the Extras where the updated driver is for the touch screen.

  • TouchSmart IQ506 touch screen problem

    Our company has recently obtained a TouchSmart IQ506 with Windows Vista 64 bit and everything works fine. We did a cool, been reformatting in the network and ran all the updates and others. As you may, or may not, know, the IQ506 isn't a VGA port to install a second monitor or to connect to a projector, so that to use the TouchSmart mirroring an image to the projector, we bought 2.0 of StarTech USB to VGA Display Adapter. I installed the drivers and got work and mirroring the image properly, however, now I'm having a problem with the touch screen.

    The touch screen responds when I touch it, but that the pointer is emptied all the way to the right. Mouse follows my pen up and down with me, but it does not come to the left. It's as if the screen is only read the coordinates there where I touch, and coordinates x are blocked all the way to the right.

    The touchscreen was working perfectly fine until I installed the graphics card driver and software for the VGA display adapter to work. The keyboard and the mouse works fine, everything is perfect except for this touch screen problem. I'm 99% sure it's a software problem, and I wanted to know if there is a known issue, or if anyone else has had this kind of problem. I guess this is the software for the VGA graphics card and I was wondering if this is the case, what I can do for the TouchSmart can support a second screen bypassing screen touch, or any other, problems of alternatives.

    Sorry in advance if there is already a topic on this issue, I went thorugh the forums and can't find anything about it.

    RasterBlaster thanks for your comment.

    I wanted to try something before your steps and I seemed to have solved the problem.

    The problem is that the nvidia card driver was not cooperating with startech to the VGA graphic card driver. I uninstalled the nvidia card driver and all this work and am now able to see on both screens.

    I know I'm going to miss some qualities of video, but from now on, everything works and I think it's what is best. I will try to reinstall the graphics driver, but right now, the problem is resolved. Thank you.

  • HP Envy M6-K022dx: can not find the driver for the touch screen

    My hard drive crashed and I reinstalled Win 8.1 on a new hard drive. I downloaded the drivers and everything works except the touch screen. No response when I touch it. There is no driver touch screen under HP support. A ran Supprt tune and it does not show the touch screen drivers. Tactile, used to work, and Yes, this model has the TouchSmart/digitizer touch screen. How can I get the touch screen works again?

    Hello @Sparky855,

    Thanks for the quick response!

    Looks like you need to install Windows 8, with all the drivers of origin supplied with the product.  Try first to review this document, to see if you can restore the drivers of Recovery Manager: Computers HP - use of the Recovery Manager to restore software & drivers (Windows 8)

    If this isn't the case, then you may need the recovery of Windows 8 media.  Here you can find media recovery for Windows 8: recovery - TouchSmart from HP ENVY m6-k022dx support Sleekbook media

    Try using the recovery media, install Windows 8 with all the original drivers.  Therefore, you can upgrade back to 8.1 for Windows.  Make sure to save your Windows 8.1 image just in case.  You can use the following documents to help you, if necessary:

    HP computers - create a recovery Image on disc or save a recovery Image on a USB drive (Windows 8)

    HP computers - create and use a Microsoft recovery USB drive (Windows 8)

    I hope this helps.

    Please let me know if this information helps you solve the problem by marking this message as 'accept as Solution' , this will help others easily find the information they seek.  In addition, by clicking on the Thumbs up below is a great way to say thank you!

    Have a great weekend!

  • I have improved my all-in-one for windows 8 and the touch screen does not

    Hello, I have an acer aspire one, and I just bought and installed upgrading windows 8 from the Microsoft site. He installed an "auditor of system" 1 who reported a few minor problems, but none of them were associated with wifi or touchscreen. after upgrade both the touch screen or wifi do any work! Good start of Microsoft! Why can't just work? "Anyway - I googled a little and found this is normal and I should have installed a pre-upgrade Acer 1 pack?  Is is true that I can't find it anywhere and I wonder if it exists, can someone point me in the right direction and also let me know if I can install it now that I have already installed windows8! Thank you all

    FReeZA... Thanks a lot for your help!  everything is working now and Windows 8 work well on this machine!  I also had to upgrade the driver for the wireless card get that work and found them on this page as well as the touch driver that you sent me!  Thanks again. http://www.Acer.co.UK/AC/en/GB/content/drivers

Maybe you are looking for

  • Buttons do not work on a Satellite P300D

    Hello, first post here, with a call for help! The buttons do not work and the 'next' button is locked and keeps me sharp when I shut down the computer. In addition, I believe that this does not sound to get the laptop to the TV, even if the image is

  • ISE and self-registration

    Ciao,. is it possible to send information, user identification and password, created by self, via email or SMS? For example: -user connect open ssid. -Open the browser and ISE after redirect, current comments http portal with automatic registration,

  • mirror image to transfer to the material

    I have a HP Officejet 6600 and have a document in Office/Publisher I would like to print a reverse/mirror image on transfer paper.  I studied various sites but none have my referenced particular printer.  Any help will be greatly appreciated.  Thanks

  • Display based on SYBASE DB object

    Hi allI use version JDev 11.1.1.4.Currently, my requirement is to created readOnly viewObject based on the SYBASE DB table.If during treatment of the ViewObject creat step I get error below, when the request of VO is in TESTQuery: select LeadUniqNum,

  • Ghost race

    CS6 - shows a black line on the objects created without, and even when the object is sent to the back rest in the front running. Very odd behavior, but it is only on this specific issue.