BlackBerry - how to properly manage a TAP/CLICK in a custom handler

I need to set up an event of click/tap for a custom Manager.

The Manager contains a few items, but I need that all respond to the event Manager, so if the user taps/clicks No matter what item in the Manager, the event handler should be called also. What I've done is to attach a changeListener to a NullField which takes the width and height, but the fieldChanged method is never called

public class TestManager extends Manager{
    private BitmapField _icon;
    private LabelField _lblTitle;
    private NullField nullField;
    public TestManager(Bitmap pIcon){
        super(Manager.FOCUSABLE);
        _icon = new BitmapField(pIcon);
        _lblTitle = new LabelField("This is the title");
        nullField = new NullField(NullField.FOCUSABLE);
        add(_icon);
        add(_lblTitle);
        add(nullField);
            nullField.setChangeListener(new FieldChangeListener() {

        public void fieldChanged(Field field, int context) {
            doSomething();
        }
    });

    }

    public void doSomething(){
    System.out.println("do something!!");
}
    public void paint(Graphics graphics)
    {
       graphics.setColor(Color.DELIMITER_COLOR);
       graphics.fillRect(0, 20, Display.getWidth(), 50);

       super.paint(graphics);
    }

    protected void paintBackground(Graphics arg0) {
       arg0.setColor(Color.LIGHTGRAY);
       arg0.fillRect(0, 0, Display.getWidth(), Display.getHeight());
       super.paint(arg0);
    }

    protected void sublayout(int width, int height) {
        setPositionChild(_icon, UIFactory.getBestX(10), UIFactory.getBestX(8));
        setPositionChild(_lblTitle, UIFactory.getBestX(60), _topMarginTitle!=0?UIFactory.getBestX(_topMarginTitle):UIFactory.getBestX(15));
        setPositionChild(nullField, 0, 0);
        layoutChild(_icon, width, UIFactory.getBestX(50));
        layoutChild(_lblTitle, width, UIFactory.getBestX(50));
        layoutChild(nullField, width, height);
        setExtent(width, height);
    }

      protected boolean navigationClick(int status, int time){
            invalidate();
            doSomething();
            return super.navigationClick(status, time);
        }

}

How can I do this whole handler to respond to a click/tap?

I use the API 5.0

Thanks in advance!

The problem with the help of the NullField of to do, it's that NullField is not programmed to handle any interaction except update.

If you need to replace navigationClick, like you did for the Manager.  So that it connects to your plumbing FieldChangeListener (which is the right thing to do in my opinion. you must call fieldChangeNotify, for example):

        protected boolean navigationClick(int status, int time) {
                this.fieldChangeNotify(2);
                return true;
        }

Now you will replace it in the NullFeld because it gets the focus.  You must make sure that nothing else in the Manager is focusable.

But you will need some guidance in the manager who is has the focus, so that the user knows - especially for when the user is using the trackpad.  To do this, make a focusChangeListener for the NullField Manager and have the listener code set a flag if the focus was acquired or not and then invalidate() himself.  In object check the flag and if it is set, paint for focus, if not, paint for any developed.

Come back if this is not clear.

Byt the way, the sublayout in your manager looks a bit ropey to me, it's especially this:

setExtent (width, height);

You really want to show to what extent being large enough to accommodate all your field and no more.

There are other things that I'm not sure, but if it works for you, then I guess it's OK.

Good luck

Tags: BlackBerry Developers

Similar Questions

  • The basics on how to properly manage the profiles when you work with LAB color?

    Hello

    I need to incorporate several color blocks in an InDesign document. I have the colors in a list as a LABORATORY values. The document will be printed, and I have the profile for the combo printer/paper that we intend to use.

    One of you would be willing to walk me through the workspace, the color management policies and Assign/convert setings profile should I use to get the best result?

    And, more precisely - assuming that I use the color Panel - no color chart - color in blocks: what settings should I use Inorder for me to rely on the warning "out of gamut" provided to warn me if I try to use a color that doesn't print correctly?  I don't care if it is out of gamut for the purposes of my screen - it's whether out-of-gamut phew for printing purposes and I want to know.

    Are all the colors in the document you send really Lab? If this is the case your color settings and profiles have no effect on these colors. Your printer will convert colors to CMYK Lab somewhere in their workflow, and it will be for them to choose the right destination profile. If you know what will be their destination the CMYK profile, it would not hurt to apply it to your document, but it's their choice, of the for use or not when they exit your file.

    Know your printer that you send color Lab?

  • A question about how to properly manage a single timer on a screen, when to schedule and cancel?

    A matter of design, which is a good implementation of the following?

    I have a single class that extends screen. In this class, I have a unique clock and the internal class that extends TimerTask.

    public class MyScreen extends MainScreen {
    
      private Timer _t;
    
      private class MyTask extends TimerTask{
        public void run() {
        ...impress your girlfriend with cool logic...
        }
      }
    }
    
    • What is the best place to set the timer to run the timer whenever the screen is loaded?

      1. Constructor
      2. ScreenUiEngineAttachedListener
    • What is the best place to cancel the timer to ensure truly cancelled once the user has closed the screen or press the physical end on the device?

      1. ScreenUiEngineAttachedListener
      2. onClose
      3. keyDown
      4. .. .or all this?

    Is it advisable to use?

    Thank you.

    Do not start and cancel the timer - create, plan and cancel TimerTasks!

    Have a static _t private timer = new Timer(); -This way, you will have just one per application (at least for this class), statically initialized. Cancel the timer just before you shut down the application. Plan all your TimerTasks on a single clock.

    Your question then becomes "when can I plan and cancel my TimerTasks?" It depends on your specific needs for your TimerTasks, but the right places would be:

    Annex:

    Screen.onDisplay () / onUiEngineAttached (true)

    Screen.onExposed () (if you go the road of onObscured() below)

    Screen.keyChar () / keyDown() / keyControl() (if you go with the DeviceInfo.getIdleTime check () below)

    Screen.navigationClick () (see above)

    Screen.touchEvent (see above for touchscreen devices only)

    To cancel:

    Screen.onUndisplay () / onUiEngineAttached (false)

    Screen.onObscured () (pairs with onExposed() above)

    If (DeviceInfo.getIdleTime () > yourTimeoutValue inside) TimerTask.run () method - must also deal with the above-mentioned keyChar/keyDown, the navigationClick() and the touchEvent() then.

    One thing to keep in mind - a TimerTask actively running will drain your battery pretty quickly by preventing your phone to enter a low power mode, so don't forget to cancel it when you don't need. On the other hand, a timer 'active' without any scheduled on that, go to sleep just forever, so don't bother killing/recreate.

  • I can not sincronize my Blackberry Desktop Manager with Windows Live. I get the message "unknown error reported" How turn off the connected BlackBerry smartphone advanced power management features

    I'm on resolution 5, I used four different resolutions and none of them work, and I do not understand how to apply the meanless 5. Resolution 5

    Turn off the connected BlackBerry smartphone advanced power management features. For more information about how to disable the USB selective suspend feature in Windows, visitMicrosoft Help and Support site and search for "disable usb selective suspend."

    See if http://support.microsoft.com/kb/902274 help
    --
    ..
    --
    "andresgn" wrote in message news: 9754 c 356-97ed-4b9f-8dc5-c3318a6dc60b...
    > I'm on resolution 5, I used four different and no resolutions are
    > work them, and I do not understand how to apply the meanless 5.
    > Resolution 5
    > Turn off the connected BlackBerry advanced power management features
    > smartphone. For more information about how to disable the selective USB
    > suspend functionality in Windows, see the Microsoft Help and Support site
    > and look for "disable usb selective suspend."
    >
     
     
  • How do I open the browser web blackberry with a url given by a click of a button.

    Hi all

    I'm developing an application in which I want to open the browser web blackberry with a URL given using a click of a button. How can I do that. I use this code inside the earpiece button

    ' Public Sub fieldChanged (field field, int context) {}
    TODO self-generating method stub
    Private private = Browser.getDefaultSession ();
    browserSession.displayPage ("http://www.google.com");
    }

    What is a good way to do this? Please help me...

    Yes

  • I was doing a winpeshl.exe.error when starting "the application was not properly initialze (0xc0000006). "Click to complete the application.

    I was doing a winpeshl.exe.error when starting "the application was not properly initialze (0xc0000006). "Click to complete the application" when I click ok it reboots. I can even recover the system, tried F8 startup, alt/F10, F2, launch repair system, Safe Mode and all the rest and still get the same error. System specs are Acer Aspire 5920, Intel T5450 processor, 2 GB ram, 160 GB of HDD, windows vista edition Home premium.  I am currently under the memory diagnostic tool windows, but it is said that the test results will be displayed again once you log in, but I can't log in to view them.  The test seems to be hanging around 21% so I don't know how well it will do

    Hi A1W1LL,

    A clean boot helps eliminate software conflicts.  Let us check if software is causing the problem by following the clean boot procedure that may help you resolve the issue.

    To perform the clean boot procedure, follow the instructions in the link below.

    Step 1: Perform a clean boot
    Step 2: Enable half the services
    Step 3: Determine whether the problem returns
    Step 4: Enable half of the startup items
    Step 5: Determine whether the problem returns
    Step 6: Resolve the problem
    Step 7: Reset the computer to start as usual

    How to troubleshoot a problem by performing a clean boot in Windows Vista
    http://support.Microsoft.com/kb/929135

    After reviewing the issue, put the computer into Normal mode.
    Uninstall or update the program that is causing the problem.

    If you are not able to boot to the desktop, you can try to restore your computer from WinRE.

    1. Insert the Windows Vista installation disc in the disc drive, and then start the computer.
    2. Press any key when the message "Press any key to boot from CD or DVD".
    3. Select a language, a time and currency, and a keyboard or input method, and then click Next.
    4. click on repair your computer.
    5. in the System Recovery Options dialog box, select the drive of your Windows installation and click Next
    6. in the System Recovery Options dialog box, click System Restore.
    7. follow the instructions in the wizard to restore system as usual and choose the appropriate restore point.
    8. click Finish to restore the system.

    Please post back and let us know if it helped to solve your problem.

    Kind regards
    KarthiK TP

  • How can I implement two tap double finger in bb10?

    Hello everyone.

    For my application, I want to implement two JJUJ tap double gesture. Bb10 I found that there is a support of two fingers tap.

    Can someone please suggest me how to use it, or what will be the procedure of implementation?

    Thank you.

    After a bit of digging around, I found This example of handling multitouch on GitHub. Have not tested so no idea if it works with the current SDK. briefly looking at the code, I don't think there's a manager built tap, but you could listen to a sequence of Touch Touch Release Release Touch release Touch released in quick succession.

  • Smartphones blackBerry how can I fix this error: "The XML is not well-formed."

    What is this error?  "The XML is not well-formed."

    I was always able to access the site of ringing in the AT & T Mall until today.   All of a sudden, I get the error XML, as shown above.

    What is it?  How should I do?

    You change the option in the configuration of the browser for something other than blackberry.  You can change it to Internet Explorer or Firefox.  I've noticed this problem when I try to access my Bank Web site and the web address think that it is accessed from a blackberry browser and not a general public.  Now when you download things like themes that you get from a site of third party... where they send you a txt message to click on a link you must replace blackberry.  Here are the instructions for how to do this:

    Open the browser

    Click the button (Menu) Blackberry

    Scroll down to Options

    Click on the browser Configuration

    Under the browser Indentifcation change to Internet Explorer or Firefox

    Then try again ringtone site.

    Let me know if it works

    Thank you

    PBKolsun

  • How you properly structure layers in Illustrator to create character animator keyboard triggers?

    How you properly structure layers in Illustrator to create character animator keyboard triggers? I was able to trigger several layers are displayed, but after the first layer, I lose the ability to control the eyes, eyebrows, etc.  The tutorials have for example Photoshop, but there is none for illustrator.  I work in illustrator and would not have to move around with Photoshop.

    Thank you, Mark.

    When you configure multiple views puppets (that is, by pressing keyboard triggers to switch to profile/quarter views), you need to adapt the behavior of the Face and behavior of lip sync (if do lip sync), the puppet of top level down to the individual view subpuppets. For your work or any other configured in this way, follow these steps:

    1. In the project Panel, select the puppet.
    2. In the properties panel, remove the face and Lip Sync behaviors.
    3. Double-click the puppet to open it in the Panel of the puppet.
    4. Whirlpool open character > subpuppet Chief (in your example) so you can see the layers view subpuppet.
    5. Select all the layers in view subpuppet (in your case, currently, before and on the right side).
    6. Add the behaviors of face and Lip Sync in the add behavior menu ('+ ') in the properties panel. This allows you to adjust the settings on a view-by-view basis.

    Now, that you trigger different views, your facial expressions and speech can still control the character's face.

    It is also covered in this FAQ: FAQ: why my character's mouth does not work at the outbreak of a default (front) view for a puppet multivue?

    I hope this helps.

  • How do you manage virtual interfaces for Macbbok

    How do you manage virtual faces for macbook pro?

    I guess that you are referring to the virtual faces on a network?

    System Preferences > network > gear icon > manage virtual faces

  • How do you manage automatic renewal on subscriptions

    iPhone 6 IOS9

    How are they managing automatic renewal subscription on some apps

    See this support article for instructions:

    MANAGE SUBSCRIPTIONS

    See you soon,.

    GB

  • How do simulate you a right-click of the mouse on the touchpad?

    How do simulate you a right-click of the mouse on the touchpad?

    You open the Boot Camp Control Panel and put in place the pad to work how you want it to run. I have the lower-right corner of the touch pad as a right click.

  • How can I configure the double-click on a Magic Mouse 2 without the universal access icon?

    How can I configure the double-click on a Magic Mouse 2 without the universal access icon?

    --> Mouse system preferences.

  • How can I change the "right click" menu for a table control?

    Hello

    How can I change the "right-click menu" of a table control. I would like to be able to remove the ability to add or remove columns and maybe more selections. I want to keep the possibility of

    Add or remove lines

    Right-click on your table.  Then go to advanced-> DURATION Shortcut Menu-> Edit.

  • How can I manage the downloads when I connect to the internet?

    How can I manage the downloads when I connect to the internet?
    When I connect to the internet, this prevents the download and update or I don't know what else
    How can I activate all things off whenever I want to?

    Hi MiladNataj,

    ·         What you download?

    ·         Did you do changes on the computer before the show?

    ·         What web browser do you use?

    Performs a search using the Microsoft safety scanner.

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

    Note: The data files that are infected must be cleaned only by removing the file completely, which means that there is a risk of data loss.

Maybe you are looking for

  • Satellite P100 - 429 LAN wireless has stopped working

    I had a satellite P100-429 during about three weeks, the wireless card was working fine until yesterday. Today I turned on the laptop, but I can't connect to my access point. In fact the laptop can now find any wireless network at all. Can anyone hel

  • BlackBerry smartphones to change icons that appear on the home screen

    Hi all: Any new owner of the 9000. I've had three questions for you gurus: (1) is there a way that I can choose which icons appear on the home screen, so that I don't not to hit the MENU button and then scroll to access ones I use regularly...? (2) A

  • Driver_Power_State_Failure on Lenovo U310

    Hello! I just got my Lenovo for about a month and then it started to do this "Driver power state failure" error whenever I have try to wake my computer from sleep or if I leave my computer unattended for some time. I don't know much about computers i

  • I have hp elitebook 8440p, I inserted the sim card, but I'm not able to see where to configure the sim card

    Hi I have a hp elitebook 8440p but I did not; KWN how to use sim card option, I inserted the sim card, but now I can't see wher to configure the sim card or use, cos I m unable to see any option, so please help me

  • vCenter Linked Mode Upgrade w

    Guy.I have two servers vCenter running (5.1) and 5.1U1 facility in bound mode. I plan to upgrade them both to 5.5 b and want to make sure that I understand the process regarding the related modes. I feel I will break the connection related modes befo