Focus with GridFieldManager problem

I'm having a problem of development/unfocus.  A label should draw a border of red around him when it gets the focus and a black border when he loses it.  But when I add/remove a label for a GridFieldManager (see below the code and the screenshot), I find that the update will temporarily to the field at (0,0) and 'loses' never the focus - in other words, he draws a red border, but never black.  So, I end up having 2 fields with the red border - something that should never happen!

I'm under 5.0 SDK on Eclipse.  I reproduced the problem in the simplest possible form: If you import the following code, you'll see for yourself.  Please help me!

Import net.rim.device.api.ui.XYEdges;
Import net.rim.device.api.ui.component.LabelField;
Import net.rim.device.api.ui.container.GridFieldManager;
Import net.rim.device.api.ui.container.MainScreen;
Import net.rim.device.api.ui.decor.Border;
Import net.rim.device.api.ui.decor.BorderFactory;

/ public final class screen extends MyScreen
{
private GridFieldManager MDT;
   
public MyScreen()
{
Set the displayed title of the screen
setTitle ("MyTitle");
int size = 3;
GFM = new GridFieldManager (size, size, GridFieldManager.FIELD_HCENTER |) GridFieldManager.FOCUSABLE);
for (int y = 0; y)< size;="" y++)="">
for (int x = 0; x)< size;="" x++)="">
LabelField nf = new LabelField ("H", LabelField.FOCUSABLE) {}
protected boolean navigationClick (int time, int status) {}
swap (this);
this.setFocus ();
Returns true;
}

Protected Sub onFocus (int direction) {}
this.setBorder (BorderFactory.createSimpleBorder (new XYEdges (1,1,1,1), new XYEdges(0xFF0000,0xFF0000,0xFF0000,0xFF0000), Border.STYLE_DASHED));
}
                   
protected void onUnfocus () {}
this.setBorder (BorderFactory.createSimpleBorder (XYEdges (1,1,1,1))) of new;
}

};
nf.setBorder (BorderFactory.createSimpleBorder (XYEdges (1,1,1,1))) of new;
               
GFM. Add (NF);
}
}
Add (GFM);
}
   
private void swap (LabelField lf) {}
GFM. Delete (LF);
GFM. Add (LF);
}
}

Thus, even if I clicked on the intermediate element, an area of development is established around the item to (0,0)

Why is this?

Sorry to get to this post, this late - I could have saved a lot of traffic if I noticed it earlier...

In any case - onUnfocus has a very strange behavior. In some cases (I don't know which) it is not called at all when the field loses focus. So, rather than using onFocus/onUnfocus pair, use FocusChangeListener. This listener will turn on the eventType and onFocus on FOCUS_GAINED work and the work of onUnfocus on FOCUS_LOST.

Overall, it will look like this:

import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.GridFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.decor.Border;
import net.rim.device.api.ui.decor.BorderFactory;

public final class MyScreen extends MainScreen
{
    private GridFieldManager gfm;

    public MyScreen()
    {
        // Set the displayed title of the screen
        setTitle("MyTitle");
        int size = 3;
        FocusChangeListener fcl = new FocusChangeListener() {
          public void focusChanged(Field field, int eventType) {
            switch (eventType) {
            case FOCUS_GAINED:
              field.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1,1,1,1), new XYEdges(0xFF0000,0xFF0000,0xFF0000,0xFF0000), Border.STYLE_DASHED), false);
              break;
            case FOCUS_LOST:
              field.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1,1,1,1)), false);
              break;
            case FOCUS_CHANGED:
              break;
            default:
              break;
            }
          }
        };
        gfm = new GridFieldManager(size,size,GridFieldManager.FIELD_HCENTER|GridFieldManager.FOCUSABLE);
        for (int y = 0; y < size; y++) {
            for (int x = 0; x < size; x++) {
                LabelField nf = new LabelField("H", LabelField.FOCUSABLE) {
                    protected boolean navigationClick(int time, int status) {
                        swap(this) ;
                        this.setFocus();
                        return true;
                    }

                };
                nf.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1,1,1,1)));
                nf.setFocusListener(fcl);

                gfm.add(nf);
            }
        }
        add(gfm);
    }

    private void swap(LabelField lf){
        gfm.delete(lf);
        gfm.add(lf);
    }
}

You will notice that I have created a FocusChangeListener to listen each LabelField and changed calls setBorder on focus has changed not update in page layout (as does not change the size of the border), which will make it much more effective and does not cause the entire screen redraw

You can do even better if you setBorder on the ground as it is created, but use the long form - viewable one following first parameter. Define borders forVISUAL_STATE_FOCU andVISUAL_STATE_NORMA at least. Again, take a long look at prototypes withupdateLayou indicator. This way you won't have to worry about changes in development at all - the system will do it for you

Tags: BlackBerry Developers

Similar Questions

  • TreeField focus with image problem set as background?

    Hello

    I have a treefield with an image as the background for its elements. Now, the problem occurs when the child is to the point. The image that is displayed as a child was similar to the text intendation. I don't want that. I want to have the entire line with the image.

    No idea how to go on this issue.

    Hello

    This has been fixed with the TreeField invalidateNode method.

  • How to focus with live view on 70 d

    Hello

    My girlfriend recently bought the 70 d and while that it "is a neat device, we would hit a problem: how to place your focus using live view in M mode?
    I want only to place the point and to focus with half the press as usual. Instead, when I place the focus by pressing the touch screen, it should be immediately shot.

    And why there is no possibility to move the update using the wheel apperture as on my 6 d?

    Thank you much in advance.

    N.B: Please excuse my English

    When in live view, you can use the rear dial to move the focus "place".

    As for the second request, when in mode live view press the info button to bring up the options. Take a look in the lower left corner, there is an icon that allows you to enable or disable the option to instantly take the photo. It will show it OFF or

  • Verizon said I can be faced with one problem with my browser and don't charge but ATT, gmail and other

    Tried loading Verizon homepage, but it says I can be faced with a problem with my browser. ATT, gmail between other fine load and Verizon was very well for some time now, what should I do? I'm not tech savvy so please keep it simple for me, thank you.

    Try to clear your browser's cache.

    Firefox button or tools > clear recent history... - details and of course Cache hit only is selected, and then select all and click the clear now button.

  • Presario SR1463CL with drivers problems

    Please be tolerant of beginners.

    I purchased a SR1463CL to add to a DELL Dimension - old but never fails. -the HARD drive was crushed. I replaced the HDD Samsung with Western Digital. I have replace the dial-up modem. All this without problems. I installed Windows XP Pro and SP2 update. My system detects "New hardware" drivers VGA Compatible and multimedia controller. I have had no success finding the right drivers and their installation. My monitor works find, but I have no sound.

    Poster 'sounds, video controllers' Device Manager with the problems. Initial device showed sound and audio by default to the Modem. I removed which and at this point no device is indicated.

    Device Manager shows no driver found for new hardware and online search has failed. Windows Update detects any is available. I checked on the resource one manufacturing line have failed in my downloadsfrom RealTek and Nvidia.Dial - up has had major periods and material has been identified as there's no way for the system. Previous owner had made the back-ups-DVD-but they went "purple haze" and could not be read. That's why I installed XP Pro.

    My modem does not work on and additional time. It will connect and funtion but after a few minutes I'll get "Page not found" displayed.

    So, I use my Dell Dimension for internet troubleshooting. Any help is greatly appreciated.

    Respectfully.

    "Submariners do it deeper."

    Thanks for the information. Due to serious conflicts resulting from auto-updates from microsoft, which I had to reformat the HARD drive and have located since the necessary drivers to the www.sis.com for VGA and www.realtek.com for audio AC 97 readers to be precise. Manually review and choose downloads in the future.

    "Greens, all councils prepare to dive."

    Thanks again for your help. It is greatly appreciated.

    Bamabubblehead went to the abyss.

  • My macbook air running hot and the battery drains quickly can help you with this problem?

    My macbook air running hot and the battery drains fast is a 13 ", at the beginning of 2014.  Processor 1.4 GHz intel core 15Can you help with this problem?

    Apps can affect the performance of Mac, battery, temperature and fan activity - Apple Support

  • just installed new update for itunes. When I go to the page stoe it flashes really hurt. anyone with this problem. is there a solution?

    just installed new update of itune. When I go to store the page, it's really bad flicker.  anyone with this problem. is there a solution?

    Widely not reported, no known resolution until Apple release a new version of iTunes that affects it.

  • two drivers of PXI chassis with Configuration problem

    Hello

    I have two PXI chassis. One is PXI 1033 and works perfectly with the NI PXI-5404, 5105, 6509, 1409, installed 8336. The other is 1036 PXI with the PXI-5404 NI, 8366 installed. When I was trying wreath connect, as master 1033, 1036 as slave, I found several problems.

    1. in the Measurement & Automation Explorer, does not have my good guys in 1033. Instead, there is a sign of the Red Cross in bottom right with 6509, 5105, 5404.

    2. I can't find an another 5404 of the 1036. In fact, I can't find 1036 in MAX.

    Update BIOS. My PXI system is already identified under the name 'NOR PXI - 1033 Embedded MXI Express' and Chassis1 is identified as 'NOR PXI 1033'.

    So I made several tests as below:

    1. unscrew the 5404 1036 slave. MAX can configure 2 1036 chassis. Ok. But when I reconnect 5404 in 1036, same result happened as stated above.

    2 uninstall the driver of 5404, so the 5404 in 1033 does not either now. And then reboot again, same result happens again. Cannot detect the 1033 chassis. Other vouchers in 1036 don't work either.

    Please, any suggestion is highly appreciated.

    Sincerely,

    Bin

    Hi Ben,

    This happens sometimes with MXI-Express:

    Error code 12 with MXI-Express

    http://forums.NI.com/T5/PXI/two-PXI-chassis-connection-with-configuration-problem/m-p/1475876#M9033

    In general, you can read this error 12 means on Device Manager:

    Explanation of error codes generated by Device Manager in Windows XP Professional

    http://support.Microsoft.com/kb/310123

    If it was a problem of bandwidth, PCI or PXI side, you could pull a few cards to see if that alleviates the problem, or that the link from Microsoft over the States, you can disable the driver for other cards.

  • When you install the 2007 Microsoft Office Suite Service Pack 2 (SP2), I still received the error code 646... I tried to download the RegCure as advised, but the problem still exists... Please help me with this problem... Thank you

    Ideas:

    • When you install the 2007 Microsoft Office Suite Service Pack 2 (SP2), I still received the error code 646... I tried to download the RegCure as advised, but the problem still exists... Please help me with this problem... Thank you

    I tried to download the RegCure as advised, but the problem still exists...

    Who advised you to 'download... '. RegCure? Doing so could only worse issues! If you ever think that your registry database must be cleaned, repaired, boosted or optimized (it isn't), read http://aumha.net/viewtopic.php?t=28099 and draw your own conclusions.

    See http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/6e716883-7af4-4a9f-8665-2f4dd57eee8d ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • Using the auto focus with a tripod

    What is the recommendation for the use of the auto focus with a tripod and remote wireless shutter release?

    It depends on the subject. If autofocus could "fool" by distracting elements (i.e. shooting a bird in a tree where branches could 'steal' the update) and then proceed to the manual. If AF would work pocket so no reason to switch to MF.

    If the lens has Image stabilization to consult the manual of the lens. Some require IS be turned off when on a tripod.

  • I have a frozen screen of Active recovery of white desk with a mouse. I think that the computer is frozen upward with a problem of recovery? Right?

    I have a frozen screen of Active recovery of white desk with a mouse.  I think that the computer is frozen upward with a problem of recovery? Right?

    How can I fix?

    Hello
    • What were the changes made before the problem occurred?

    You can try to restart the computer and check if it helps.

    If above does not help, you can read the following steps to disable the active desktop on the computer and check:

    a. to disable Active Desktop.
    b. right click on an area empty office, point to Active Desktop, and then click view as Web Page to clear the check box.
  • I need a list send me Windows based utility of magnification for XP, am a MSN user with vision problems and cannot zoom in easily on what I have.

    I need a list, sent me to my XP Windows-based magnification utilities, am a user of MSN base with vision problems and cannot zoom in with what I have, and the work of the "Magnifier" somewhat well but could use something better.

    Any ideas?

    Hello

    Please refer to the links and check if it helps.

    How to set accessibility features for people who are blind or who have low vision in Windows XP

    http://support.Microsoft.com/kb/308978

     

    Windows XP accessibility tutorials

    http://www.Microsoft.com/enable/training/windowsxp/default.aspx

    Overview of the magnifying glass

    http://www.Microsoft.com/resources/documentation/Windows/XP/all/proddocs/en-us/magnify_about.mspx?mfr=true

    I hope the information is useful!

  • I am also having the same problem with the same updates. I have Windows XP SP3 and it's updates with the problem.

    I am also having the same problem with the same updates. I have Windows XP SP3 and it's updates with the problem.

    Security Update for Microsoft .NET Framework 2.0 SP2 on Windows Server 2003 and Windows XP x 86 (KB2572073)
    A security update for .NET Framework 2.0 SP2 and 3.5 SP1 on Windows Server 2003 and Windows XP x 86 (KB2518864)
    Security Update for Microsoft .NET Framework 2.0 SP2 on Windows Server 2003 and Windows XP x 86 (KB2633880)

    They all install properly but switches back to windows update to install. It's some kind of loop.

    Hi billy73,

    In addition, if you still have questions, please take a look at the thread similar here with a solution as possible.

    I hope this helps!

  • New SSD speed with u410 problem

    Hi, I would ask about my problem. Yesterday I had my old ssd Dams in my ideapad u 410 with one

    A - Data 32 GB SP300 first Pro

    Data sheet:

    Read: 280 MB/s.
    Writing: 260 MB/s.
    IOPS / s: read 12 500/writing 46 000 (random maximum write 4 K)

    and runing on Windows 8 profesional x 64. When I run Crystal diskmark my results are lower as the old 24GB ssd card, I am now around 47 MB/sec write, the old ssd played 69 MB/sec.

    Can someone help me with this problem?

    Thank you.

    renamed topic

    Some ssd compress the data and give you a speed of data compress in their specifications, your old ssd drive might not make it.

    Crystal diskmark performance and go towards the senior, the file / test data / select all 0 x 00 (population 0) and rerun the test.

    John.

  • WHEN I OPEN INTERNET EXPLORER THE E-mail INSERT attachment only WILL NOT WORK - BUT OPEN WHEN IT WITH ADD - no one seems to help me with this problem?

    WHEN I OPEN INTERNET EXPLORE THE INSERT ATTACHMENT WILL WORK - BUT WHEN HE OPENS WITH ADD - NO ONE SEEMS TO HELP ME WITH THE PROBLEM OF TIS!

    That means '' BUT WHEN OPEN IT WITH ADD? '' With no Add-ons? Have you tried allowing add-ons one at a time until you find out that one is the cause of the problem?

    "NO ONE SEEMS TO HELP ME WITH THE PROBLEM OF TIS!

    Have you thought to ask in the forum Internet Explorer?

    Internet Explorer forums
    http://answers.Microsoft.com/en-us/IE

Maybe you are looking for

  • Satellite L745 - how to remove the keyboard safely?

    Hello, people! I need help please. As the topic says, how to remove the keyboard?It's because I shared tea on my keyboard and, fortunately, no key was damaged. However, now it is sticky, and it is quite annoying! Can someone please help me with the e

  • program installation problem

    I am trying to unstall a msi program, it starts to load then it stops and there is an error code and then says access denied

  • Failed to update Windows for KB973768; MSG for error 0x8007F0F4

    Clean recently re-installed Windows XP Media Edition + SP2 and SP3 on the computer at home. Downloaded 124 updates from Windows Update. Cannot install KB973768. Error msg is in the subject line. I tried to update several times. Windows Update continu

  • While playing online games, I get this message. McAfee service as host encountered a problem and must close.

    Error messages I have Windows XP Home Edition. While playing online games, I get this message. McAfee service as host encountered a problem and must close. McAfee, as tried to help him stop for a day, then did it again. As MS sent me on this forum as

  • The parser error

    Whenever I turn on my computer, two boxes appear indicating that I have an error in the parser.  We're with HPHC_Scheduler.exe and the other is GfxUI.exe.  They both say C:/windows/microsoft.NET/Framework/v2.0.50727/config/machine.config.  Parser ret