How to detect loss of keyboard focus?

I’ve got a numeric input field that must be padded with
leading zeros to exactly 8 digits. The handler to pad the input is
trivial and calling the handler on various mouse events is equally
simple, however, I would also like to call the handler when the
input field looses keyboard focus by tabbing. Apparently, keyDown
events are not passed for the tab key when auto tabbing is engaged.
Anyone know if there is an event triggered by loss of focus?

There is no onBlur event in Lingo (though something like it
would be a
useful addition). You'll need to poll for keyboard focus.

Similar Messages

  • Loss of keyboard focus in Java appl running under linux

    I have a small sample program that replicates my problem. When this program is run a window is created. If you select File->New another instance of the program window is created. Now if you try to go back and bring to front the first window, keyboard focus is not
    transferred when run under linux. You can only type in the second window. The expected behavior does happen in Windows.
    > uname -a
    Linux watson 2.6.20-1.2933.fc6 #1 SMP Mon Mar 19 11:38:26 EDT 2007 i686 i686 i386 GNU/Linux
    java -versionjava version "1.5.0_11"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)
    javac -versionjavac 1.5.0_11
    import java.awt.event.*;
    import javax.swing.*;
    class SwingWindow extends JFrame {
        SwingWindow() {
         super("SwingWindow");
         JMenuBar menuBar = new JMenuBar();     
            JMenu fileMenu = new JMenu("File");
            JMenuItem newItem = new JMenuItem("New");
            newItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent event) {
              SwingWindow.createAndShowGUI();
         fileMenu.add(newItem);
            menuBar.add(fileMenu);
            setJMenuBar(menuBar);
            setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);       
         JTextField text = new JTextField(200);
         getContentPane().add(text);
         pack();
         setSize(700, 275);
        public static void createAndShowGUI() {
            JFrame frame = new SwingWindow();
            frame.setVisible(true);
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

    You can implement the FocusListener interface. When
    the first JFrame gains focus, call
    text.requestFocusInWindow(). I hope this helps.The call requestFocusInWindow is not helping, perhaps even making it worse.
    The problem seems to be that I am in the situation where the call
    KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner()
    is returning the expected Component. The problem is that the KeyListener class that is registered with the Component is not being called when a key is being pressed.
    The issue is that I have a component that has the keyboard focus, but the KeyListener class
    is not responding.
    This seems to be a linux only problem which makes it only mysterious.

  • 508 accessibility and keyboard focus

    I'm using Captivate 4 and can't seem to get the keyboard accessibility to work properly. I want to be able to control the tab order and keyboard focus on each slide. For example, if the user keeps pressing tab they will eventually move from the .swf file and begin reading the address and menu bar in the browser window. Does anyone know how to ensure that the keyboard focus is provided only to active elements?

    Hi,
    I noticed your post while searching for the same answer with respect to Captivate 5.  So far, it is the closest I've seen to the problem I'm trying to resolve.  I see that you had no luck here, but was wondering if you found a solution elsewhere.  All help would be appreciated.

  • How to detect if an item of JComboBox is highlighted?

    Good day.
    How to detect if the selected item of a JComboBox is highlighted or not?
    Thanks for your response.

    the above code can only detect a highlight if an item is selected from the combo box.
    But when the focus is transfered to other Combo box it can no longer keep track if the item was highlighted or not.
    for example:
    combo box 1 combo box 2
    item item2
    Highlight should be detected wheneverr the focus is transfered from combo box 1 to combo box 2 or vice versa.
    case:
    Combo box 1 item is highlighted before transfering the focus to combo box 2 item. by the time the focus is transfered , highlight in combox 1 item should be detected.
    The main problem here is how to detect if the previously focused item is highlighted or not.
    thank you for your time.

  • Does anyone how to detect a cherry G84-4100 keyboard on mac os lion?

    does anyone how to detect a cherry G84-4100 keyboard on mac os lion? Mine is not detected and the keyboard is working

    Found a partial solution by connecting another usb device and then connect the keyboard. The problem seems to be whitin the detection of the usb keyboard.

  • How to detect what keyboard is currently active on desktop?

    Hi there, I'm working on a virtual keyboard (window with buttons as keys) for my swing application. When I show keyobard window I would like to adjust the layout of my virtual keyboard to system keyboard that is currently active on desktop. But I don't know how to detect what keyboard is currently active. How to detect this? Thank you.

    I answered my own question - see
    http://forums.ni.com/t5/LabVIEW/Loading-and-Running-a-VI-on-a-cRIO-from-a-PC/td-p/796657
    On the Real-Time CompactRIO Properties > VI Server, you must check the box for TCP/IP protocol, which by default is unchecked.
    Also, when you make a Build Specification for a VI and set it to run on startup, you can still enter the VI name (not c:\ni-rt\startup\startup.rtexe) as the VI Path on the Open VI Reference.

  • How safari detects and pops up 'scan credit card' link in keyboard ios 8.1?

    How safari detects the credit card number,CVV and security fields and adds 'scan credit card' link in keyboard. This s a new feature added in ios 8.1
    I want to check whether is there a way to disable it?

    An update.  Just after my first post I cleared history yet again, restarted yet again and started watching what I got when I tried to use the history to skip back a few pages.  Just now I discovered it was stuck on pages I visited at least 24 hours ago.  This is pure untested garbage, and I say that from the perspective of a 45 year IT career.
    I Miss Steve - and, yes, my iPad decided to capitalize that m all by itself...

  • How to programmatically know Outlook has been fully loaded and opened with keyboard focus?

    Is there a way to know programmatically that Outlook has been completely opened with keyboard focus (C#)?

    You need to specify the parent window handle. I have already replied to your question, see Outlook
    window getting the keyboard focus instead of user created Form Window during Outlook Startup .

  • How to detect the key enter with a numerical control without using loop event?

    I want to accept a numerical value only when the key enter is pressed, but without using the event. How to detect the char "enter" with a numerical control?
    Thanks!

    When the user edits a numeric control with a keyboard, its property "key focus" is true. When the user hits enter, key focus becomes false. Poll the property to latch the control valuse at the true-false transition. That won't work if the user modify the control using up and down arrows.
    LabVIEW, C'est LabVIEW

  • JComboBox popup list remains open after losing keyboard focus

    Hi,
    I have noticed a strange JComboBox behavior. When you click on the drop down arrow to show the popup list, and then press the Tab key, the keyboard focus moves to the next focusable component, but the popup list remains visible.
    I have included a program that demonstrates the behavior. Run the program, click the drop down arrow, then press the Tab key. The cursor will move into the JTextField but the combo box's popup list is still visible.
    Does anyone know how I can change this???
    Thanks for any help or ideas.
    --Yeath
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    public class Test extends JFrame
       public Test()
          super( "Test Application" );
          this.getContentPane().setLayout( new BorderLayout() );
          Box box = Box.createHorizontalBox();
          this.getContentPane().add( box, BorderLayout.CENTER );
          Vector<String> vector = new Vector<String>();
          vector.add( "Item" );
          vector.add( "Another Item" );
          vector.add( "Yet Another Item" );
          JComboBox jcb = new JComboBox( vector );
          jcb.setEditable( true );
          JTextField jtf = new JTextField( 10 );
          box.add( jcb );
          box.add( jtf );
       public static void main( String[] args )
          Test test = new Test();
          test.pack();
          test.setVisible( true );
          test.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    }

    ran your code on 1.5.0_3, observed problem as stated.
    even though the cursor is merrily blinking in the textfield, you have to click into
    the textfield to dispose the dropdown
    ran your code on 1.4.2_08, no problems at all - tabbing into textfield immediately
    disposed the dropdown
    another example of 'usual' behaviour (involving focus) breaking between 1.4 and 1.5
    the problem is that any workaround now, may itself be broken in future versions

  • I would like to detect all the keyboard key is okay, but not every key can be detected by using LabVIEW example, keyboard keycode

    I would like to detect all the keyboard key is okay, but not every key can be detected by LabVIEW example ( we can use 『basic input demo.vi』to detect normal key』.
    I want to detect some 『hot key』 for example some keys exist in the upper part like 『search key』、『e-mail key』、『volumn control key』...etc. They are very often to be watched in some new keyboards, but we still don't know how to detect if their functions are okay.
    Can we detect signals of these 『hot key』 in LabVIEW? We can apply these hot key's functions in XP, so we should detect their signal, I think, but I can't do it.
    I serach some information about this question, and somebody said we can detect hot key's signal by grabing 『keybode』 these hot key feedback. But I don't know how to do these. I can't use VC. So anyone can give me a LabVIEW VI to grab keycode? Or any other solution we can detect all the key on the keyboard, including hot keys?
    Thanks!
    Regards,

    Maybe that is the limitation of Acquire Input Data.vi.The vi can't identify the Unformal key.
    You can try to use Event structure and set to listen "key down" event.
    There are two terminals VKey, ScanCode will sent out the information when you press key.
    There are two pictures in attached file, 2.jpg will show you the detail.
    Good luck.
    Attachments:
    SpecialKey.zip ‏17 KB

  • Outlook window getting the keyboard focus instead of user created Form Window during Outlook Startup

    This MAPILogonComplete method involves creating a Form Window to show "What's New" of a certain Addin version (DisplayWhatsNewDialog() in the code):
    private void _outlook_MAPILogonComplete() {
    _logger.Info("_outlook_MAPILogonComplete");
    try
    if (_timerForm != null)
    _timerForm.Timer.Stop();
    _timerForm.Timer.Dispose();
    catch (Exception ex2)
    _logger.Error(ex2.Message, ex2);
    try
    if (Globals.BJNSettings.showWhatsNew)
    Globals.BJNSettings.showWhatsNew = false;
    UIHelper.DisplayWhatsNewDialog(false);
    Ol.Inspector insp = null;
    if (_inspectors.Count > 0)
    for (int i = _inspectors.Count; i >= 1; i--)
    insp = _inspectors[i];
    WrapInspector(insp);
    insp = null;
    Ol.Explorer expl = null;
    if (_explorers.Count > 0)
    for (int i = _explorers.Count; i >= 1; i--)
    expl = _explorers[i];
    WrapExplorer(expl);
    expl = null;
    GetAddinsList();
    Thread logSystemInfoThread = new Thread(new ThreadStart(LogSystemInformation));
    logSystemInfoThread.TrySetApartmentState(ApartmentState.STA);
    logSystemInfoThread.IsBackground = true;
    logSystemInfoThread.Start();
    try
    Ol.NameSpace ns = _outlook.GetNamespace("MAPI");
    _calFolder = ns.GetDefaultFolder(Ol.OlDefaultFolders.olFolderCalendar) as Ol.Folder;
    _calFolder.BeforeItemMove += new Ol.MAPIFolderEvents_12_BeforeItemMoveEventHandler(_calFolder_BeforeItemMove);
    _delFolder = ns.GetDefaultFolder(Ol.OlDefaultFolders.olFolderDeletedItems) as Ol.Folder;
    Marshal.ReleaseComObject(ns);
    ns = null;
    catch (Exception ex)
    _logger.Error(ex.Message, ex);
    UIHelper.WriteDoNotDisableKeyToRegistry();
    Globals.AppointmentsToProcess = new List<string>();
    _timerForm.ProcessTimer.Interval = 3000;
    _timerForm.ProcessTimer.Start();
    catch (Exception ex)
    _logger.Error(ex.Message, ex);
    DisplayWhatsNewDialog() has this signature:
    public static void DisplayWhatsNewDialog(bool modal)
    try
    string defaultWhatsNewFile = Globals.BJN_APP_BASE_DIRECTORY + "WhatsNew.txt";
    string localISOLanguageName = Languages.GetTwoLetterISOLanguageName();
    string localizedWhatsNewFile = Languages.GetInstalledLocalizedFilePath(localISOLanguageName, "WhatsNew.txt");
    if (String.IsNullOrEmpty(localizedWhatsNewFile))
    localizedWhatsNewFile = defaultWhatsNewFile;
    if (File.Exists(localizedWhatsNewFile))
    BJNWhatsNew whatsNew = new BJNWhatsNew(localizedWhatsNewFile);
    if (modal)
    whatsNew.ShowDialog();
    whatsNew.Dispose();
    else
    whatsNew.TopMost = true;
    whatsNew.Show();
    whatsNew = null;
    catch (Exception ex)
    _logger.Error(ex.Message, ex);
    The problem is if the Window is made modal, it blocks the Outlook to launch and also goes back of the Outlook loading window (Whats New window will not be having keyboard focus). And if the Window is made non-modal (passing false to DisplayWhatsNewDialog()),
    Outlook launches properly and What's New window comes at the top but will not be having keyboard focus; instead the launched Outlook window will be having the keyboard focus. May anyone please suggest a way to make the What's New window to be always having
    the keyboard focus? Structure of form window class BJNWhatsNew is given below:
    public partial class BJNWhatsNew : Form
    private static ILog _logger = LogManager.GetLogger(typeof(BJNWhatsNew));
    public BJNWhatsNew(string whatsNewTextFileName)
    InitializeComponent();
    InitLabels();
    InitEventHandlers();
    InitWhatsNew(whatsNewTextFileName);
    private void InitLabels()
    try
    this.Text = Properties.Resources.bjn_version_info_caption;
    this.buttonClose.Text = Properties.Resources.ok_hotkey;
    this.labelBJNAddin.Text = Properties.Resources.bjn_version_ol_addin;
    this.labelVersion.Text = String.Format(Properties.Resources.version_format, Assembly.GetExecutingAssembly().GetName().Version.ToString(3));
    Assembly assembly = Assembly.GetExecutingAssembly();
    FileInfo fileInfo = new FileInfo(assembly.Location);
    DateTime buildDate = fileInfo.LastWriteTime;
    string formatString = "d MMM, yyyy";
    this.labelReleaseDate.Text = String.Format(Properties.Resources.bjn_version_release_date, buildDate.ToString(formatString));
    catch (Exception ex)
    _logger.Error(ex.Message, ex);
    private void InitEventHandlers()
    this.buttonClose.Click += new EventHandler(buttonClose_Click);
    private void InitWhatsNew(string whatsNewTextFileName)
    try
    if (File.Exists(whatsNewTextFileName))
    StreamReader sr = new StreamReader(whatsNewTextFileName);
    string whatsNew = sr.ReadToEnd();
    sr.Close();
    this.richTextBox1.Text = whatsNew;
    this.richTextBox1.SelectionLength = 0;
    this.buttonClose.Select();
    this.buttonClose.Focus();
    catch (Exception ex)
    _logger.Error(ex.Message, ex);
    void buttonClose_Click(object sender, EventArgs e)
    this.Close();

    Hello Prasad,
    The ShowDialog method will block the current thread. If you want to continue working with Outlook objects you need to use the Show method instead. The key fact is that both methods (Show and ShowDialog) accepts an instance of the IWin32Window interface
    which allows to specify the parent window handle. Specifying the parent window handle (Outlook Explorer window) to the Show method you can make your window shown on top of Outlook all the time.
    To get the HWND of an Outlook explorer  object (e.g. Application.ActiveExplorer), cast it to IOleWindow and call IOleWindow.GetWindow(). Also you may find the
    How to get the IWin32Window for Outlook
    article helpful.

  • How to detect key board event

    HI,
    How to detect keyboard event (Like CTRL key press shift key press) in Swing�any can any body suggest classes and interface for that�.
    Thanks

    [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]How to use Key Bindings

  • Why does the keyboard focus keep switching to the menu bar?

    Does anyone else have the problem of Photoshop CS6 constantly setting the keyboard focus to the menu bar? This makes it difficult to use shortcuts.
    Typical examples: I want to switch to the Move tool, so I press V, but instead, the View menu drops down. Or I press T for the Type tool, but instead, the Filter menu drops down. This happens often and it's very annoying.
    This also happens in Premiere Pro CS6, and happens on both my Windows 7 and Windows 8.1 machines. Doesn't happen in other applications, and is not related to actually using a menu, i.e. if I choose something from a menu, then press V, Photoshop will often work correctly and activate the Move tool. This behavior seems to happen randomly.

    Alt doesn't really "unhide" the menu bar (speaking of Photoshop), but it's always been the introducer of keyboard operations for "keyboard accessbility" - i.e., operation of Windows applications without mouse.
    Alt causes little underlines to show up under the key characters of menu items, and prepares the system for the next character being typed to open a menu - so for example you press something like 'e' and the Edit menu pulls down.  Now you use an arrow key to move to the next item, or maybe a single character that's associated with one of the menu entries.
    Photoshop's goals for using modifier keys kind of conflict with this.  They've apparently tried to reach a balance where using the Alt key to modify some operation cancels the introduction of the next menu item. 
    But I don't think it's possible to be perfect at that, especially for example if the user presses Alt, decides not to do the operation he was thinking about doing (e.g., zooming out), then just releases the key.  Another factor might be the habits people get into for choosing tools.
    As a contrast, one person might not press the Alt key until they're sure they're going to do something with it (e.g., zoom out), and that same person might only choose tools from the Tools panel by clicking on them.  Another person might press the Alt key sometimes, but then stop before doing the operation it modifies.  That same person might be in the habit of choosing tools by their letter (e.g., E for eraser).  It's clear to see how the first person might never get into a condition where the menu introducer key (Alt) leaves them in a state where a menu opens inadvertently, while the latter might see it regularly.
    As far as why Photoshop might get into a mode where the menu introduction occurs when you HAVEN'T pressed the Alt key, I don't know; I certainly haven't seen that reported much if at all here on the forum.
    -Noel

  • How to Detect Database Conneciton Lost in Applet

    Hi,
    Is there a way to detect loss of database conneciton or network conneciton in an applet while it is running? We have an applet application and want to perform some database updates based on loss of database or network connectivity while the applet is running.
    Just thinking out loud - is there a way to use some thread that constants runs in the loaded applet code and checks for database or network connectivity.
    Thanks

    That will be a manual process since we will know the list of users who had logged in thru the logs. What we are trying to do is to limit the concurrent connections for the users to the system. So if a conneciton is lost the users current count has to be decremented.
    The select query you mentioned is trivial but how can we make this run all the time in the background. Do we use some thread etc?

Maybe you are looking for

  • Bootcamp 5 & windows 7

    should i install bootcamp 5 on windows 7

  • Apple video cable technical question

    I can not seem to find the answer to this question anywhere... I have the Apple component AV cable and the Composite video AV cable. I have measured the resistance of all the pins and compared to the posted pinout web sites. I am confused about the p

  • DVD drive won't recognise 10.4 upgrade disc.

    Our lovely old G4 comes with a DVD drive - no burner, but the reader is in there. I can play DVDs just fine; but it's (finally) time to update from 10.1. I have an upgrade disc for a previously overwritten update on a different mac and figured I'd us

  • How to clear the Residual & partial payment through app

    Hi Experts, How to clear the Residual and partial payment through app in accounts payable i tried but i am not getting the out put so plz clarify the my question and any other configuration for that give answer with example... Thanks for advance Rega

  • Installing SQL developer on windows 7

    Hi all, Please has anybody successfully installed Oracle SQL developer on windows 7 (64 bit system)? I have been trying to do that for some time now but it has not worked out? I even downloaded the beta version of JDK i.e. JDK version 7 on advice fro