Touch anywhere on the screen calls the ListField TouchEvent.DOWN

Hello

I suffer with small complex issue. In the screen of my application, I have the title bar with a labelfield and two custom buttons.

Below the titlefield I add a list field.

Now, I have a few complex features on the field from the list. When I click each line in the list, it should move to another screen I do using navigation, click medium. Now if I touch the rank in the list (for touch devices), it should move to another screen. And if I touch along the line of the list, it will display popup menu (custom, not by default) with option of removal and details.

        mListItem = new ListField(length, ButtonField.CONSUME_CLICK)
        {
            long touchedAt = -1;
            long HOLD_TIME = 500;

         // The regular getFieldAtLocation returns wrong values in open
                    // spaces in
                    // complex managers, so we override it
//                  public int getFieldAtLocation(int x, int y) {
//                      XYRect rect = new XYRect();
//                      int index = getFieldCount() - 1;
//                      while (index >= 0) {
//                          getField(index).getExtent(rect);
//                          if (rect.contains(x, y))
//                              break;
//                          --index;
//                      }
//                      return index;
//                  }
            protected boolean navigationClick(int status, int time)
            {
                // Click related functionality
                return true;
            }

            protected boolean touchEvent(TouchEvent message)
            {
                if(message.getEvent() == TouchEvent.DOWN)
                {
                     if (getFieldAtLocation(message.getX(1), message.getY(1)) == -1)
                     {
                         Logger.out("AccountList", "Touch down: getField location");
                         return true; // kill the event
                     }
                     else
                     {
                         touchedAt = System.currentTimeMillis();
                         touchedonList = true;
                         Logger.out("AccountList", "Touch down: touched down  "+touchedonList);
                     }
                }
                else if(message.getEvent() == TouchEvent.UP )
                {

                       if(System.currentTimeMillis() - touchedAt < HOLD_TIME && touchedonList == true)
                       {
                           touchedAt = -1; // reset
                           // Single Touch and Move to another screen
                       }

                       else if(touchedonList == true)
                       {
                         // Showing Menu Popup
                       }
                }
                return true;
//              return super.touchEvent(message);  // Not using this as it will show the default pop up
            }

And here's my reminder list field:

public class ListCallBack implements ListFieldCallback
    {
        public void drawListRow(ListField listField, Graphics graphics, int index,
                int y, int width) {

            String strdomOrg = yyyyyyy;
            String text = xxxxxx;
            Font f = FONT_FAMILY_0_SF_AS_08;

            int h = f.getHeight();
//          int height = (listField.getRowHeight() - h)/2 ;
            int height = h/2 ;
            y += height;
            graphics.setFont(f);
            graphics.setColor(Color.BLACK);
            graphics.drawText(strdomOrg, 10, y, DrawStyle.ELLIPSIS, width);
            y = y + h;
            graphics.setFont(FONT_FAMILY_1_SF_AS_08);
            graphics.setColor(Color.BLACK);
            graphics.drawText(text, 10, y, DrawStyle.ELLIPSIS , width);

         // use the offset instead
            int offset = (listField.getRowHeight() ) >> 1;
            if (index != 0) {
                graphics.drawLine(0, y - offset , width, y - offset);
            }
        }

        public Object get(ListField listField, int index) {
            // TODO Auto-generated method stub
            return mAccounts[index];
        }

        public int getPreferredWidth(ListField listField) {
            // TODO Auto-generated method stub
            return screenWidth;
        }

        public int getPreferredHeight() {
            return getContentHeight();
        }

        public int indexOfList(ListField listField, String prefix, int start) {
            // TODO Auto-generated method stub
            return listField.getSelectedIndex();
        }

    }

Now the question is to come a different way:

1. whenever I touch the buttons in title field, he calls the listfield TouchEvent.DOWN. Then the click of a button does not work. Instead, by clicking on the title bar, it moves to another screen, which is the feature click list filed.

2. so I added the listfield at a value for money. :

m_vfmScreen = new VerticalFieldManager(VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR)
        {

        protected boolean touchEvent(TouchEvent message) {
                int event = message.getEvent();
                if (event == TouchEvent.CLICK) {
                    if (getFieldAtLocation(message.getX(1), message.getY(1)) == -1)
                        return true; // kill the event
                    else {
                    }
                }
                return super.touchEvent(message);
            }

            // The regular getFieldAtLocation returns wrong values in open
            // spaces in
            // complex managers, so we override it
            public int getFieldAtLocation(int x, int y) {
                XYRect rect = new XYRect();
                int index = getFieldCount() - 1;
                while (index >= 0) {
                    getField(index).getExtent(rect);
                    if (rect.contains(x, y))
                        break;
                    --index;
                }
                return index;
            }
        };

While in the list key of field works. If I touch the buttons in the title bar, it does not. But if the keys become focus, this case they work.

So I am in dilemma, what exactly the problem. Can someone please help.

For me, there's a code unepxected in your touchEvent() - getFieldAtLocation().  If you want released supporess presses of field, I suggest you use code like this:

protected boolean touchEvent (TouchEvent message) {}

int x = message.getX (1);
int y = message.getY (1);
If (x < 0="" ||="" y=""> < 0="" ||="" x=""> getExtent () .width: y > getExtent () .height) {}
Outside the scope
Returns false;
}

Tags: BlackBerry Developers

Similar Questions

  • Thunderbird has started recently popping up big yellow 'notes' if I spend too long anywhere on the screen. How can I stop?

    There was a recent update, and now when my cursor rests almost anywhere on the Thunderbird window, big yellow notes pop up, describing everything that I'm hovering above. I want to disable this feature.

    I wish I could get a capture screen, but every time I try, the pop up disappears.

    I use a Mac and the 24.6.0 version

    Are you sure that you do not have an add-on you do this? I'm running worm. 24.6 on a PC and I've never seen that happen.
    You can restart with Add ons disabled in the Help menu.

  • My iPad2 (iOS9.2) has locked up. I can turn on and off, but he can't see the icons. Cannot touch and change the screen.

    My iPad with iOS 9.2 2 locked. I can click it and outside. There is no guest sign in code. He immediately opened to the icons, but I can't switch to another screen icons. When I touch one of the icons, nothing happens. No movement at all. Even the clock doesn't change. Does anyone else have this problem?

    Try resetting your device. This will not erase your data stored on that device.

    • Press and hold the sleep/wake button
    • Press and hold the Home button
    • Press and hold both buttons until the display turns off and on again with the Apple logo on the subject.
  • Touch a touch monitor moves the cursor to respond on a different system Windows Vista multi-display monitor

    Hello!

    I joined just a touchscreen multi-touch Dell ST2220T the VGA on a Toshiba laptop. The multiscreen correctly display features, however touch events on the new monitor are sent to the screen of the laptop. There doesn't seem to be a way to make the new monitor the primary monitor, as in something similar here. In addition, if the option to solve this problem in a similar way to this solution exists in Windows Vista, it is certainly well hidden. I've sifted through all the options in Vista and came away empty-handed.
    No one knows how to fix this problem on WIndows Vista with a built-in screen that can not be changed by default?

    Hello

    Is the touch screen as the default monitor?

    Set up your touchmonitor active by default. To do this follow the steps mentioned in the link below

    Change-Display-Settings-on-multiple-Monitors

    http://Windows.Microsoft.com/en-us/Windows-Vista/change-display-settings-on-multiple-monitors

    For more information, see the links below

    Set up multiple monitors
    http://Windows.Microsoft.com/en-us/Windows-Vista/set-up-multiple-monitors

    Understanding multiple monitors
    http://Windows.Microsoft.com/en-us/Windows-Vista/understanding-multiple-monitors

  • Detect the finger up/down on the screen

    Is it possible to detect a touch generic event on-screen little matter to which component is affected?
    I need to know when the finger is the screen down and to the top of the screen to manage a specific behavior on the app.

    How about something like:

    onTouch {}
    If (event.isDown ()) {}
    Start the timer
    }
    else {if (event.isUp ())}
    off timer
    }
    }

    And this applies to the container root of UI

  • How to display the scroll bar on the listField

    I use the following code to add a listField to VerticalManager, but he couldn't display a vertical scroll bar.

    Thanks for any help.

    Michael

    SerializableAttribute public class ContactsListField extends VerticalFieldManager
    {

    .......

    public ContactsListField (int width, int height, string keyword)
    {
    Super(Manager.NO_VERTICAL_SCROLL |) Manager.FIELD_HCENTER);
            
    managerWidth = width;
    managerHeight = height;
    VerticalFieldManager vor = new VerticalFieldManager(Manager.VERTICAL_SCROLL |)
    Manager.VERTICAL_SCROLLBAR | Manager.FIELD_HCENTER | Manager.FIELD_VCENTER);
            
    listField = new ListField(0,ListField.FOCUSABLE)
    {
    public void paint (Graphics g)
    {
    getManager () .invalidate ();
    Super.Paint (g);
    }
    };
            
    listCallback = new ListCallback();
    listField.setCallback (listCallback);
            
    contacts = getData();
    If (contacts! = null)
    filterKeyword (keyword);
                        
    VFM. Add (ListField);
    Add (VFM);
    }

    Hmm... nothing extraordinary.  One might want to draw focus in the ListField by defining a suitable background and foreground colors, but still - there is nothing that would prevent the drawing of the ScrollBar by the Manager.  Of course, Manager.FIELD_VCENTER is not used in the optimization of resources, and I suspect that FIELD_HCENTER will be useless too (I think ListField uses all of the default width).  You can delete these two style bits.

    One thing to check - what can you add that ContactListField to?  If it's a screen or a derived class, you must use NO_VERTICAL_SCROLL in the constructor.  In this way, you will ensure that is vfm that manages the painting "scrollbar".

  • bitmap image clears I scroll in the listfield and not repainted

    Hi all

    I try to use a single bitmap for the listfield, who owns 10 list (for example). I am just placing bitmap b4 but it erases just the user scrolls and don't then repainted. Please help me find the solution.

    public MyCallback()
        {
            dest = new XYRect(5,5,20,20);
            bitmap = Bitmap.getBitmapResource("icon_select.png");
        }
    
        public void drawListRow(ListField listField, Graphics graphics, int index,
                int y, int width)
        {
            String text = (String) list.elementAt(index);
            dest.y+=15;
            graphics.drawBitmap(dest, bitmap, 0, 0);
            graphics.drawText(text,25, y+3,0,width);
        }
    

    also how to make this bitmap appears as it is b4 every name I.

    This is b4 scrolling. and after scrolling it looks like.

    Please help me find the solution

    average u when focus you and unfocus the individual line.

    If it's problem so look for drawFocus, u can try calling inavalidate inside...

    can u post a larger excerpt

  • I suddenly lost Microsoft Powerpoint, Word and Excel: right click anywhere on the desktop or the folder &#62; &#62; New &#62; &#62; Excel or Word or Powerpoint. How to bring back this ability?

    For a long time, I always made the following steps to create a new file in Word, Excel, Powerpoint, or Visio:

    1 - right click anywhere on the desktop (or inside any folder)

    2 Select 'new' from the context menu that is displayed > select Word (or Excel or...)

    3 - Filename is [you are prompted for... and so on.

    A few days ago this ability to disappear quietly.  I did not have any new software installation or reconfiguration, other than the usual Windows updates (if there is one) and update MS Security Essentials.

    How do I return this very useful feature?

    Hello

    You have discovered a problem with Windows 7. To resolve this problem, I recommend a program called FileMenu Tools. You can download the portable freeware from here: http://www.softpedia.com/get/PORTABLE-SOFTWARE/System/System-Enhancements/FileMenu-Tools-Portable.shtml .

    After having downloaded and installed the program, you will notice that, by default, each option is checked. I would be much more selective on this subject, otherwise your context menu will be a full page long! When the main window opens, you will see a list on the right side of all the elements that can be added to the context menu. Start weeding through the list and every one to take away, you don't need the United Nationsby checking the box.

    Once you have completed your selection (de-selections) make sure that you click the green check mark in the row of icons at the top of the left window of the interface to 'Apply' of your choice. The program can do much more, but that answers your specific question. I am told that the program has a good help file, so try here if you are interested.

    Let me know if this solves the problem for you.

    Kind regards

    BearPup

  • Slide paused continues when I click anywhere on the slide - why? (CP5)

    Hi - end of the CBT I create, I present some challenge questions.  I do not use the Quiz feature that I have not need enter the student responses.

    I added a blank slide with an image with captions of reversal.  I added a "continue" button, then they can go to the next page, after they are made to review the image.

    Everything works fine, the breaks of slide, so they have time to right-click the image, and leads to the next page when you click on the button continue.

    The strange thing is that it also goes to the next page when I click anywhere on the screen.  This only happens on these three blades, the rest of my film does not progress when you click on the background.

    For the slide, I put it on enter = continue and exit = No Action display time = 3 seconds

    For the button continue, I put it on success = go to the next slide, attempts = 1, the last attempt = go to the next slide, break after = 1.1 s

    Anyone know why when I click on the slide, it goes to the next slide?  I want to slide to pause until it only the button is clicked.

    Thank you!

    Your continue button is being set up so that if the learner does not click on the button action of the last attempt will be used.  By default it is to continue.  So while you want only the user to go to the next slide, if they clicked on the button, by setting attempts on 1, you said Captivate any click outside the button should invoke the action of breaking for this button, which will be to continue to the next slide.

    Try setting your button to the attempts of the infinite.  This disables the action of failure.

  • I would use Yuanti SC police for my web development project. However, my developer is not able to use the file .ttc I extracted from the library of fonts, and .ttf, .otf .woff formats not available anywhere on the web.

    I would use Yuanti SC police for my web development project. However, my developer is not able to use the file .ttc I extracted from the library of fonts, and .ttf, .otf .woff formats not available anywhere on the web. Please, let me know how can I use this font for my project.

    Thank you

    Anton

    Unless the site you develop is for the Asian market, I don't know why you want to use that particular font. The Basic, standard and digital alphabet punctuation glyphs has sans serif, Roman characters, but the rest is thousands of Kanji characters. While you can use the font .ttf and .otf and web fonts, it would be very unusual to use one so great. Pages should load quickly and 78 MB, with a value of faces to download for those who have connections slow Internet is not fast.

    I would take a different font without serifs. There are literally thousands who look identical or virtually identical to Yuanti.

    131 free and high quality without font serif to choose here. I'm sure you can find a desired.

  • When I go to tools-&gt; account settings, Thunderbird freezes and simply emits a sound without action, when I click anywhere in the application.

    I can't access my account settings. When I try to access account settings by navigation in tools-> account settings, TB freezes and simply emits a sound from there to the front when I click anywhere in the application. I have to close TB via the Task Manager and reopen it. Enjoyed every appeal. Thank you

    What happens in safe mode? Hold down the SHIFT key while you start Thunderbird.

  • How to stop multiple self-switching to the address bar every time I open a new tab and try typing something anywhere outside the address bar?

    How to stop multiple self-switching to the address bar every time I open a new tab and try typing something anywhere outside the address bar? As something just wants me to use this integrated search when you type something non-Web-address in the address bar and press to enter. And the most ridiculous thing is that happens repeatedly on as every second, as I just got off the address bar and start typing again, but still he passes me in the address bar, then 3, 4 times like that. And the result is that I don't see the address of this page.

    I think that its has something to do with my AVG Antivirus, because it started the same time a Nation AVG started to appear in each new tab I opened (and which is irritating as me, I've read here on support.mozilla.org and it seems that the only solution is to completely reinstall Firefox, but I don't want to lose all my settings) but when I type something in the address bar and press enter It opens the search results in Google.

    Please try to help me, I love Firefox but I have to switch to Chrome until I fix this.

    Thanks in advance

    First of all, please update Firefox 32. 22 is no longer support is not safe. So, let us know if you still have this problem. Update Firefox to the latest version

  • VZW iPhone is unlocked? Means it can be used with a SIM card, anywhere in the world with any other SIM card from another provider, including the United States

    VZW iPhone is unlocked?

    Means it can be used anywhere in the world with any other SIM card from another provider, including in the USA?

    Yes, only bought it for full price directly from Apple.

    Buy from anywhere else or under contract with Verizon means that he will probably be locked.

  • On my old iPod Touch (4th generation), the music application does not open

    On my old iPod Touch (4th generation), the music application does not open. Everything will work as before. I suspect it has something to do with the position that the app was (in podcast lists) before the last sync. How can I get the app to open again?

    If you have not already, restart the iPod touch

    Restart your iPhone, iPad or iPod touch - Apple Support

  • The bookmarksdrop in the menu drop-down is too big, as it covers the greater part of my screen - how can I make it smaller.

    Whenever I select the menu drop down Favorites, it is so big that it covers the major part of my screen. Then, when I go to a folder in the drop-down menu, if I stop to any other folder, it opens and is so great that the menu drop-down or completely covered. This is VERY irritating and I never had this problem before moving on to Firefox 5.0. How do I don't cure it?
    I use a MacBook with a 13 "screen

    It is probably because you have one or more bookmarks with a long title.

    The width of a column in the list of bookmarks is in the current versions of Firefox automatically adjusted the bookmark with the longest name.

    You can check the names of the bookmarks and the longer more short.

Maybe you are looking for

  • Can't access Gmail FF31 but can in IE

    Clear cookies and history/cache does not help. In reading your forums, it seems to be that a widespread problem so obviously is not as simple as the compensation on things.

  • New version will not work with the yahoo toolbar. How can I solve this problem?

    I downloaded the new version of Firefox, and it will not work with my yahoo toolbar more. It worked fine until I updated to the new version. I went back to the old version 16.0 and now he repeats to me my version is obsolete. How can I solve this pro

  • RAM 1 GB upgrade will increase the performance of the Satellite Pro M30?

    My ram size is currenty 512 MB.I have the model Satellite Pro M30.As the old model, my laptop would be faster if I increase to 1 GB

  • My price is true or false? answer me.

    I received the email for the price of the United Kingdom. WINNER NO. 4. Is it true or false? Batch number. YPB/08/APA-43658 Reference no. YPN560992008 Code.UK / + QU34005 security Amount.One million GBP

  • Connected HP printers missing

    I've had printers serval of installation with connected HP and ePrint to print from Chromebooks, all tested and working. Today, they're all gone. I had 3 printers with one account and another impression with a completely separate account. The two acc