Autofocus TextField when the keys are of type (for Qwerty devices)

I have a TextField will be used for filtering a list of items. For the Q10/5 etc I would like that it if the focus was automatically to the textfield if all keys are typed (and the keys to the first and following would go there).

I have this work by adding a KeyListener on the container Page and when I get the keyPressed signal I do:

onKeyPressed: {
   if (!field.focused) {
      field.requestFocus();
      field.text = event.unicode;
   }
}

It works, unless the user is able to type two keys quickly enough, in which case the first key goes in the field, but the second is lost.

I checked that the routine above is actually executed twice, once for every strike, and that field.focused returns true for the second sequence of keys, so this seems like a bug. Anyone have ideas on this?

If someone else has implemented something similar, could test you with two quick strikes in very quick succession (probably<50ms apart)="" and="" see="" if="" you="" get="" the="">

My original post on this: http://supportforums.blackberry.com/t5/Native-Development/Auto-focus-TextField-when-user-presses-key...

I don't know why I created a second, other than that I must have forgotten that I had done the first time where I started this one. I'll close this as an answer, but looking back at the other for the main thread.

Tags: BlackBerry Developers

Similar Questions

  • Autofocus TextField when the user presses the keys (and possible race condition)

    Someone tried to implement a device by which a TextField (or text box, I guess) automatically gets the focus when a user starts to type anything? It is very convenient to have something, at least with a phone model Qwerty, in certain situations. (A use case is where a list that is too long for the useful shortcuts, but the TextField object is used to implement a filtering mechanism that can reduce the data set to a reasonable size, and the user can then scroll just to find a target element).

    I've set up something using a KeyListener (calling requestFocus() for the TextField object) attached to the container Page, but there are problems with it.

    It's a question that the first keystroke does not render in the TextField object, since it has not a focus when the key was first struck.

    To solve that you can enter the key (event.unicode) and that insert into the TextField object, and then the following keys go on the field you want... but there is also a problem with that.

    If you type two or three buttons in quick succession, probably less than 50ms between them, you can see that even if the KeyListener gets each of them, the TextField object receives the second or, sometimes, the third, even if you can check that by the time second keyPressed/output signal arrives in your earpiece the TextField claims to have developed (TextField.focused is true).

    This seems like a bug, but maybe it's just a case of corner cascading who is inevitable, given its design... I'm not sure.

    If anyone can reproduce it, thanks for posting here. I'll do a test case to prove and will report it as a bug if you do.

    If anyone has a reliable and quality approach, please post here too! :-)

    P.S. for a good laugh, a code here that I did for my particular case, which seeks to avoid the race condition. As you can see, this is a great hack, but it works 100% reliable for me so far with a fairly comprehensive test (including the tests with the movement of the cursor, copy/paste, etc.). It's too complicated to analyze and ensure that it is really robust, however, but feel free to use... If you care enough. ;-)  http://pastebin.com/r2VUtPJC

    Have you tried setting the primaryKeyTarget it's inputRoute?

    https://developer.BlackBerry.com/native/reference/Cascades/bb__cascades__inputrouteproperties.html

    Has been added to the 10.1, which should do what you want.

    You can also achieve the same messing around with pre FocusPolicy 10.1, but it is much simpler.

  • How will I know when the capsules are on?

    Original title: caps Inspiron 1545?

    How will I know when the capsules are on?

    Hey, Vince,.

    Caps lock key are you referring?

    If you look above the keyboard on the right, you will see two fires instead of one.

    In addition, you will type in uppercase when the key is turned on

  • wireless multimedia keyboard Microsoft 1.1 on my desktop using Vista home premium and the keys are coming all wrong

    I have a multimedia keyboard 1.1 microsoft wireless on my desktop using Vista Home premium, and the keys are all coming up badly, when I type 'k' for example I get 'a' or if I type 'p' I get 'v' and give me space '9' someone can tell me how to solve this problem?

    Hi Winchesterdream,

    Welcome to the Microsoft answers community site.

    I suggest you try the following steps

    Step 1: Connect the keyboard to a different computer. If the keyboard works correctly on another computer, the port to which the keyboard was connected on the original computer may be damaged. If this is the case, contact your computer manufacturer to find out how to repair or replace the damaged port.

    Step 2: Download and install the latest keyboard software

    To download the latest drivers for the keyboard that you use, see the following Microsoft hardware Web site:

    http://www.Microsoft.com/hardware/download/download.aspx?category=MK

    Step 3: Press the SHIFT key to turn five times keys Stick On or Off and check if the problem persists.

    Let me know if it works. Good luck!

    Hope it will be useful.

    Thank you and best regards,

    KKS Vijay

  • PDF shows the blue areas where type.

    My PDF shows the blue areas where type. Can I hide these areas it looks stupid.

    Any help would be amazing.

    Screen Shot 2015-06-20 at 1.03.55 pm.png

    It is possible with JavaScript to control if highlighted field is active. The problem is that it is considered bad form to change the setting of the user preference without letting them know, or at least attempt to restore the settings when the control document closed.

    Here is a code that you can use in a routine at the level of the document that runs when the document is opened:

    Store highlight LENGTH so it can be restored when the document is closed

    and turn off the power

    var RTH = app.runtimeHighlight;

    app.runtimeHighlight = false;

    Then, in the event will be closed, you can restore the original setting:

    Restore the original settings

    app.runtimeHighlight = RTH;

  • MacBook randomly landed volume when the headphones are connected.

    Hey,.

    There is something wrong with my MacBook. When I plug my headphones, the Mac randomly landed the volume at any time. I thought the keyboard can be broken, but it doesn't happen when the headphones are connected so it may be a problem with the software (I think?). Has anyone experienced the same problem? Do you know how to fix this?

    My Mac is the MacBook Pro 15 "retina (mid-2014) running the El Capitan 10.11.6

    Please try resetting the memory NVRAM and SMC.

    Reset the NVRAM/PRAM memory.  http://support.Apple.com/kb/PH18761

    Reset the SMC. Choose the method for "If the battery is good behaviour."

    https://support.Apple.com/en-us/HT201295

  • NB100 - letters of the keys are too dark

    Hello

    I want to change because I use the PC keyboard in dim light and the letters on the keys are too dark. Is it possible to fix this?

    Thank you

    Hey,.

    What you want to change exactly?

    Sorry, but I don't really know what you mean. You're talking about PC keyboard then something about the letters of the keys are too dark... It's just confusing.

    Can explain you again please?

  • My button mute in my launch buttons fast remains red when the speakers are not dumb.

    I have a Pavilion dv7-3165dx with win 7 Home premium pre-installed, and recently, I noticed that my button mute in the quick launch buttons stopped to change to white when the speakers are reactivated. I tried to install the latest drivers for the buttons to quick launch, which did not work. Someone solved a similar problem (button remained white when cut) by installing something, it calls the Total of HP Advisor and his advice, but I can't find the program.

    IF what I post solves your problem, please, click the button 'Problem solved' on my post.
    Oh, and if I helped you, by clicking on the star of "Congratulations" on my post would not hurt my feelings ether.

    Hello

    Try download and reinstall the IDT Audio driver on the link below.

    FTP://ftp.HP.com/pub/SoftPaq/sp48501-49000/sp48830.exe

    Once installation is complete, restart the computer and see if it has no effect.

    Kind regards

    DP - K

  • If I have a virus and I restore my computer, the virus will come back to the computer when the files are restored.

    Original title: computer viruses.

    If I have a virus and I restore my computer, the virus will come back to the computer when the files are restored.

    Hello

    to be Safe side scan always media files are on before you reinstall your data

    using drives flash etc is a well known to transfer viruses, etc.

  • His laptop works only when the speakers are connected

    Problem_ZERO SOUND SOUND_Please Help!

    What do you do if your sound does not work?  I have a Dell Latitude E5500.  One minute I was listening to tunes on Youtube, and the next minute, I couldn't hear anything.   When I plug in my speakers, I get sound.  Someone please help me get my portable computer to operate with the sound when the speakers are not connected?  Thank you.

    Willy

    What do you do if your sound does not work?  I have a Dell Latitude E5500.  One minute I was listening to tunes on Youtube, and the next minute, I couldn't hear anything.   When I plug in my speakers, I get sound.  Someone please help me get my portable computer to operate with the sound when the speakers are not connected?  Thank you.

    Willy

    See if this Microsoft Help and Support link can help:
    No sound in Windows
    http://support.Microsoft.com/GP/NO_SOUND

    t-4-2

  • Field containing average function works only when the data are engaged on the same page. Does not work for fields on other pages.

    I'm having a problem with a field defined to calculate the average of eleven points fields (points 1 to 8 on page 1-9-11 on page 2). My original question was that it could exclude fields of points when they do not have information entered and adjust the average calculation (number of "divided by") accordingly.

    I had someone write JavaScript code for him, but I just found a small problem I don't know if it's something in the code or what the person who originally wrote the script cannot understand it either and suggested that I have post here.

    The middle area (located on the 2nd page of the pdf page two) seems to work exclusively with precision if at least one of the points of the fields on the 2nd page, 9, 10 (and 11) are engaged with the data. No values entered on the first page and only the first page, are for some reason any dividing by a more than expected. For example, if I fill the boxes 1, 2 and 3, it divides the total by four. If I filled just box 7, it halves. If I fill all 8 boxes on the 1st page, it divides by nine. It is corrected as soon as I get the points in one or more of the three boxes on the 2nd page points, suddenly the overall average is accurate. But if boxes 9, 10 and 11 contain no points, then the average is still inaccurate because the number of ' divide by "he uses is one more than what it should. I can't understand how to attach the form to this post, so I downloaded on Dropbox: Dropbox - used Evaluation.pdf.

    Under the direction of State: javascript came work to exclude the empty boxes when the points are entered in one of the three points of fields on the 2nd page (and more), but the average function is not accurate because it adds 1 to the number of ' divide by "in the calculation of the average If the points are only entered into the fields on the 1st page.

    Here's the code I entered in the 'Custom calculation Script' box in the 'Calculate' tab of the Properties menu of Test field:

    Initialize variables

    var num = 0;

    var sum = 0;

    Browse the input fields

    for (var i = 1; i < 12; i ++) {}

    var f = getField ("points." + i);

    If {(f.valueAsString)

    increment the counter to non-empty field

    NUM ++;

    Add the value of the running total field

    sum += + f.value;

    }

    }

    Calculate the average

    If {(num)

    Event.Value = sum / num;

    } else {}

    All fields are empty, then the empty value

    Event.Value = "";

    }

    I do not see that. Add the code of script debugging will display the results that each field is completed:

    Initialize variables
    var num = 0;
    var sum = 0;

    Browse the input fields
    for (var i = 1; i)< 12;="" i++)="">
    var f = getField ("points." + i);
    If {(f.valueAsString)
    increment the counter to non-empty field
    NUM ++;
    Add the value of the running total field
    sum += + f.value;
    }
    }
    Debug - display results as the form is filled;
    Console.Show
    Console.println (sum + "/" + num + "=" + sum/num);
    end of debugging;
    Calculate the average
    If {(num)
    Event.Value = sum / num;
    } else {}
    All fields are empty, then the empty value
    Event.Value = "";
    }

  • Illustrator slows when the leaders are on

    Hello

    I have the following problem:

    Illustrator slow a lot when the rulers are; I noticed that this happens only with active GPU performance.

    anyone else with this problem?

    My Info system is:

    WIN10

    Illustrator 2015.2.1 (19.2.1 64bits)

    Hearts CUDA NVIDIA Quadro K620 6 GB 384 (353.82 nvidia driver)

    Intel i5 2.67 ghz processor

    8 GB RAM

    Update the 361 xx. new NVIDIA drivers.

  • In the column of table when the values are grater that maximum linear axis it does not show the bar

    Hi guys,.

    In the column of table when the values are grater than there maximum linear axis it does not show the Bar.But I want to display the bar up to the maximum limit of the axis is linear without changing the limit max.

    Consider following the example:

    The values are 80 90 200 300

    and here is the result:

    Left: when I don't put maximum property of linear axis.

    Right: when I put in maximum property of linear axis to 200.

    Untitled.jpg

    Law 4th bar is not visible because the value of this bar is 300 which is excedding maxium. But I want the 4th bar to appear identical to 3 bar.

    How can I do this?

    Thanks in advance.

    Then you should change the value of Y to the maximum value.

    Another option, you should consider is changing the Render item column to reflect that the value is greater than the specified maximum value.

  • Stop method determines when the corruptions are repaired

    Hi all

    Above statement is 'Oracle 10g Ocp Guide of Certification all-in-one'. This statement "chosen shutdown method determines when the corruptions are repaired" is written in the section recovery instance.

    Now the question is, if we do normal stop, how can the database or instance to get corrupt?, Corruption can be occurred only because of the messy or 'give up' or any other breach. It can be detected only at the next startup. So this is the difficulty that corruptions are repaired at the start of the proceedings thus set out reference in question makes no sense.

    If someone can explain to me, what is submitted statement is all about?, I have.

    Thank you

    Assume that you have a server, including controller get "confused" disc and begins to generate corruption level block...

  • I try to use my Time Capsule as external hard drive. But when I look in the Finder, nothing is available for shared devices.

    I have a Macbook air running OS X El Capitan. I try to use my Time Capsule as external hard drive. But when I look in the Finder, nothing is available for shared devices. I don't know if I need to restart the time Capsule or change the wireless setting, etc. ?

    Please advise...

    The TC appears in airport utility? If not then it is probably not part of your network or is lost... upgrade installed you El Capo because there a lot of questions.

    What is the TC plugged into the network by ethernet? And configured properly? Are you to internet via the TC... but can not see his drive... that would be typical?

    Have you set Finder preferences to display the network drives? Apple keeps making it difficult for some unknown reason.

    You actually have to mount the drive TC if it appears under shared... it still may not appear if you double click on it. Under the search box on the top of the right hand you see Connect (As) box, type the name or IP address of the TC in there... Make sure that you save the password from your keychain.

    I try to use my Time Capsule as external hard drive

    For the storage of the files it is fine.

    For the execution of direct files for an application in the Mac, you are very likely to damage or corrupt the file at some point.

    And how do you do backups? Time Machine can't help you... it won't work.

    Backup is crucial, especially if you do things apple say not to do... That is to say move your photos or the iphoto library to the TC and try to use direct from there... expect any day to need a resumption of the library.

Maybe you are looking for