An unnatural focus event is killing MOUSE_RELEASE on XP

I only have this error being reported from people with XP PRO.
So I overrode the dispatchEvent method so that I could monitor every event
that was occuring because for some reason when a window lost focus then
gained focus java acted like the mouse was still held down. These are the
results I found:
So this is in reference to a TEXT_AREA. A person clicks on the desktop so the text_area has lost focus and then they click back on the text_area. Below are the events that are fired when the user clicks back on the text_area and it regains focus..
WIN98 WORKING:
WINDOW_ACTIVATED,opposite=null,oldState=0,newState=0
WINDOW_GAINED_FOCUS,opposite=null,oldState=0,newState=0
FOCUS_GAINED,permanent,opposite=null
MOUSE_PRESSED,(11,8),button=1,modifiers=Button1,extModifiers=Button1,clickCo
unt=1
MOUSE_RELEASED,(11,8),button=1,modifiers=Button1,clickCount=1
MOUSE_CLICKED,(11,8),button=1,modifiers=Button1,clickCount=1
Focus gained and 3 proper mouse events are fired
NOW
WINXP PRO:
FOCUS_GAINED,permanent
MOUSE_PRESSED,(353,221),mods=16,clickCount=1
FOCUS_LOST,permanent
FOCUS_GAINED,permanent
MOUSE_CLICKED,(353,221),mods=16,clickCount=1
INVOCATION_DEFAULT,runnable=sun.awt.GlobalCursorManager$1@3e0e27,notifier=nu
ll,catchExceptions=false
MOUSE_MOVED,(353,220),mods=0,clickCount=0
MOUSE_MOVED,(352,218),mods=0,clickCount=0
Focus is gained, mouse is pressed, then focus is lost?????? then immediately
gained???? and then mouse is clicked. The mouse released never gets fired
thus when I move the mouse around the text field it just highlights things
as if I'm holding down the mouse button. Somewhere in that odd gain and then focus the event is getting lost.
ideas?? or workarounds??

Hmmm that could be it. I've had a couple people report the problem though and they were all on XP PRO, maybe the drivers in XP are acting funny. Thanks for the idea, hopefully that's the problem.
I did find out a little more out about the focus events.
I have a class called AsmEditWindow that extends Frame.
In this frame I have two different TextAreas, each of these textAreas have there own separate focus listeners that I've set up using inner classes. So like:
msgarea.addFocusListener(new MsgAreaFocusListener());
textarea.addFocusListener(new TextAreaFocusListener());
Now on the functioning windows 98 system I Get:
java.awt.event.FocusEvent[FOCUS_GAINED,permanent,opposite=null] on text0
java.awt.SequencedEvent[] on text0
java.awt.event.MouseEvent[MOUSE_PRESSED,(11,8),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1] on text0
java.awt.SentEvent[] on sun.awt.windows.WToolkit@11946c2
java.awt.SentEvent[] on sun.awt.windows.WToolkit@11946c2
java.awt.event.MouseEvent[MOUSE_RELEASED,(11,8),button=1,modifiers=Button1,clickCount=1] on text0
The first focus event is on text0 then the mouse listeners proceed without a problem.
On the non-functioning windows XP system I get:
java.awt.event.FocusEvent[FOCUS_GAINED,permanent] on frame1
java.awt.event.MouseEvent[MOUSE_PRESSED,(353,221),mods=16,clickCount=1] on text0
java.awt.event.FocusEvent[FOCUS_LOST,permanent] on frame1
java.awt.event.FocusEvent[FOCUS_GAINED,permanent] on text0
So frame1 gains, then mouse is pressed, then frame 1 loses and text0 gains focus and the mouse_release event never gets thrown.
Is there something more that I should be posting to give insight? The code section to setup the Frame is about 95 lines so I was thinking that was too long to put in the post. If this assumption is incorrect tell me what part of the code would be useful, and I'll post it.
Thanks

Similar Messages

  • Radiobuttons and the focus event

    This is in AS2.
    Is there a 'onFocus' event for individual radio buttons,  or is it limited to the radiobutton group ?
    If there is a focus event for the buttons,  how to I set it up ?  I've set up an event listener with an 'onFocus' event,  'gotFocus' event,  'focus' event and nothing is triggered.....
    Regards,
    Rich

    If you look thru the help documents, all of the events associated with the radio button class are listed.  There is a focusIn event that the radio button inherits from the UIComponent class.  Here is an example for using it...
    var listenerObject:Object = new Object();
    listenerObject.focusIn = function(eventObj:Object) {
        trace("radiobutton1 just got focus");
    radiobutton1.addEventListener("focusIn", listenerObject);

  • Using Child Panels - cannot FOCUS events are lost?

    Hi all,
    I am working with some legacy code that my boss would like updated.  We have a background (parent) panel with many child panels that can come and go.  Typically, we have two panels - one with controls and one with a graph - visible almost all the time.  I have been trying to use FOCUS events to do some things, but one child panel (the control) appears to constantly get and lose focus.  I'm seeing this in debug mode with the breakpoints at the event code for the panel callback.  I'm careful to move the code windows away from this panel so the mouse isn't over it, but that seems to make no difference.  Do child panels get the events of the parent panels?  Also, the child panels do not appear to have max/min or close buttons in the title bar like standard windows.  Is there some way to put them there without taking the child panel out of the parent panel?
    Other things:
    1.  The boss would like to be able to resize a panel down to the point where clipping occurs, then automatically rearrange the controls so they line up vertically on one side of the panel and stop the resizing when they begin to be clipped.  I have seen this done in Java with the Layout Manager, but never in C. Any suggestions?  I know we can set a minimum resize value for a panel, but are there any easy ways to move the controls the way he wants? 
    2.  An alternative is to make a toolbar with the controls inside, but he likes the windows icon tool buttons which I don't believe we have access to in CVI.  I know we can make a command button and import an image to it, but is there a package that has the standard windows tool buttons that we can use?
    Thank you for any and all help.
    Judy Harrigan

    Hi Roberto Bozzolo
         For the parent panels and the children panels,I have some questiones to ask you ,could you tell me how I should do? Monthes ago ,I have asked the same question in NI.COM ,you  cansee the uir:http://forums.ni.com/t5/LabWindows-CVI/menubar-and-toolbar-enveloped-by-the-childpanel/m-p/1112563,
    I use :GetPanelAttribute (mainPanel, ATTR_SYSTEM_WINDOW_HANDLE, &parent);
              GetPanelAttribute (mlsPanel, ATTR_SYSTEM_WINDOW_HANDLE, &child);
              oldparent = SetParent((HWND)child, (HWND)parent); to create an mainPanel and a childPanel.
    For the mainPanel ,it contain the menubar and the toolbar,when I load the childPanel and move it,or
    click the maximize,the menubar and toolbar for mainPanel enveloped by the childpanel.I want the
    menubar and toolbar on top of the childPanel,can you tell  me  what I shoud do?
        you can see ,when I maximize the child panel,the menubar and the toolbar for the parent panel are enveloped by the child panel,also the title for child panel display under the parent title,this are very inaesthetic.and how I should do to make the child panel and the parent panel works as the windows style like the under-side example? 
        When click the maximize button for the child panel,the title for child panel disappeared and the "minimize button","renert button",and "close button" for the child panel display on the top right of the parent menubar.To all of this,how I should do,could you please help me?
    Attachments:
    result.JPG ‏91 KB

  • Focus events being received out of order

    I have a complicated applet where each component is registered with multiple focus listeners. I have several pairs of JTextFields and JButtons - textfield A, button A, textfield B, button B etc. Clicking on a JButton normally causes a JTable to be popped and focus transferred to it. Clicking on the table header or selecting a table row causes the table popup to close and the focus transferred to the textfield associated with the button.
    I'm running into a strange case where the focus is initially on textfield A. Clicking on button B causes a temporary loss of focus on textfield A. The trace shows that the focus owner is null and the permanent focus owner is textfield A. The table still gets launched. Selecting a table row causes it to close but no component has focus any more. Focus owner continues to be null, and permanent owner continues to be textfield A.
    After working on other windows in the meantime, and returning to this window I find that the focus in now back to textfield B, as it should. However, the trace shows that B has received permanent focus events. This is followed by receiving permanent focusLost events on A and then permanent focusGained events on A. At the point all in said and done, the focus appears on B.
    Does someone know why the focusGained event on B appears before focus events on A? Another strange thing in the trace was that some focus gain/loss method invocations were interrupted, another focus method invoked and the previous method resumed. I could possibly take care of this by using synchronized on all focus gain/loss methods. Also, some methods show only part of execution and not even resumed. This is still a mystery to me. I'll appreciate if someone can shed light on this.

    One of the things you'll notice is that when a text field loses focus to a right-click JPopupMenu, it is never just one foucs lost/gained pair, but rather they trade focus back and fourth a few times. This is the same when the popup closes, the focus trades back and fourth a few times.
    You are describing a similar situation between a button and a text field.
    There never was any guarantee the gained/lost events happen in any order. Also, if there is a chain of focus events, the information in the intermediate events may not be useful.
    If you really do need to understand the focus changes at an actionable level, you might want to consider writing a focus helper class that can be used to answer semantic questions about focus changes, such as, did this component lose focus because of a button click? Or was it a Popup? Or was it a Tab-keystroke?
    The focus helper can store 'hidden' information in any JComponent using JComponent.setClientProperty(Object key, Object value)...
    So instead of creating a focus listener like:
    myComponent.addFocusListener(new FocusAdapter() {
      public void focusGained(FocusEvent e) {
        // do stuff here
    });You can do it like this:
    myComponent.addFocusListener(FocusHelper.createTextFieldToButtonListener());and in that method it creates the listener like this (you might need to pass some parameters):
    public static FocusListener createTextFieldToButtonListener() {
    FocusAdapter adapter = new FocusAdapter() {
      public void focusGained(FocusEvent e) {
        recordEvent(e);
        // do stuff here
    return adapter;
    }The helper method "recordEvent" tags those components with additional information about permenant and temporary focus ownership. Also it clears hidden information that is no longer useful.
    Then later on you can give the focus helper a FocusEvent, and ask it, is this text field gaining focus because of a Tab-In, or is it because of a popup menu has closed?
    The helper constructs answers based on the hidden properties it finds in the e.getOppositeComponent() and e.getSource(). It put those properties there, so it knows what they mean, and it uses them to distinguish between useless information in the focus event chain, and the important things you want to know.

  • Focus Event

    I have a problem like this:
    I have a form with 2 text fields: Text1, Text2. If focusing on Text1 and pass focus-event to Text2, a Message_Box will show to confirm: "Do you want to change focusing from Text1 to Text2 (Y/N)?". If you choose Yes then focus on Text2, otherwise keep focusing on Text1.
    I have tried with following codes but it shows Message_Box 2 times when choosing No.
    Please help me to solve this issue.
    Thanks alot.
    import com.fss.swing.*;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import java.awt.BorderLayout;
    import java.awt.Rectangle;
    import javax.swing.*;
    import javax.swing.JButton;
    import java.awt.event.FocusAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.Dimension;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: FSS-FPT</p>
    * @author not attributable
    * @version 1.0
    public class test extends JFrame
         public test()
              try
                   jbInit();
              catch(Exception ex)
                   ex.printStackTrace();
         private void jbInit() throws Exception
              jTextField1.setText("jTextField1");
              jTextField1.setBounds(new Rectangle(21,65,226,19));
              this.getContentPane().setLayout(null);
              this.getContentPane().add(jTextField1,null);
              jButton1.setBounds(new Rectangle(132,128,73,23));
              jButton1.setText("jButton1");
              this.getContentPane().add(jTextField2);
              this.getContentPane().add(jButton1);
              jTextField2.setText("jTextField2");
              jTextField2.setBounds(new Rectangle(267,66,64,19));
              jTextField1.addFocusListener(new FocusAdapter() {
                   public void focusLost(FocusEvent e){
                        if(e.isTemporary())
                             return;
                        int i = MessageBox.showConfirmDialog(test.this,"Do you want to change focusing from Text1 to Text2 (Y/N)?","Confirm");
                        if(i == MessageBox.YES_OPTION)
                             jTextField2.requestFocus();
    else
    jTextField1.requestFocus();
         JTextField jTextField1 = new JTextField();
         JTextField jTextField2 = new JTextField();
         JButton jButton1 = new JButton();
         public static void main(String args[]) {
              test t = new test();
              t.setTitle("Test");
              t.setSize(new Dimension(400,300));
              t.setVisible(true);
    Edited by: googlecomvn on Jul 4, 2008 3:23 AM

    The way I've seen to cancel focus events is using a VetoableChangeListener:
    [http://java.sun.com/j2se/1.5.0/docs/api/java/awt/doc-files/FocusSpec.html#FocusAndVetoableChangeListener]
    import java.awt.KeyboardFocusManager;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyVetoException;
    import java.beans.VetoableChangeListener;
    import javax.swing.BoxLayout;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    public class FocusTest extends JFrame {
       public FocusTest() {
          final JTextField field1 = new JTextField("type \"text\"");
          final JTextField field2 = new JTextField("then click on me!");
          setLayout( new BoxLayout( this.getContentPane(), BoxLayout.Y_AXIS ) );
          add(field1);
          add(field2);
          pack();
          KeyboardFocusManager.getCurrentKeyboardFocusManager().addVetoableChangeListener(
             new VetoableChangeListener() {
                public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
                   if ( evt.getOldValue() == field1 ) {
                      if ( !"text".equals(field1.getText()) ) { //simple validation
                         throw new PropertyVetoException("Invalid value for field1", evt);
       public static void main(String[] args) {
          new FocusTest().setVisible(true);
    }You'd definitely get in trouble with using a JOptionPane in the change listener, though (as it would throw more focus events, requiring more JOptionPanes, etc).
    Edited by: endasil on 4-Jul-2008 8:50 AM

  • Catching a table cell focused event

    I have a JTable that I want users to input data into. One of the columns is a date field. In order to make sure the date is formatted and entered correctly, I've used a custom cell editor and renderer so the column looks like a DateTextField(a custom date field class). It works fine when the user clicks on the cell. But if the user hits the down arrow it doesn't set off the event that allows it to be edited as a DateTextField. Can you capture somekind of focus event on a particular cell and when you get a focus gained, programatically send the event that allows the cell to be edited? In case that didn't make sense, I'm trying to programatically simulate a mouse click on a table cell when it gets focus. Can it be done? If so, how? Thanks.

    Yes, I've tried that. The problem is what some people have described as a bug. There are two editing methods for JTable cells. One happens if the cell gets focus. There is no cursor and any underlying components are ignored. The second(the REAL edit) is when there is a cursor and the JTable understands that the cell is really a DateTextField. The only way I've found to achieve this is click on the cell. The number of clicks it takes depends on what the clickCountToStart is set to. However, if it's set to zero, it still takes one click.

  • [MSAA] Inspect32.exe can not track focus event in win7

    I tried inspect32.exe in my WIN7 system, in Desktop, it can retrieve all focus event and show the Detail( eg Name, Role).
    But when I get into explorer ( eg. C:\ ), the File List focus change can not be tracked by inspect32.exe.
    Not all win7 system has this problem, so I guess some "MSAA" or "UIA" component is missing. 
    Does anybody know how to fix this? Thanks very much!
    I download MSAA 2.0 RDK, but can not be installed in WIN7.

    May be inspect is not able to find the handle of the window or control is not exposed to outer word.
    Thanks
    Rupesh Shukla

  • How to catch cell lost focuse event of matrix

    Dear all
    can you tell me how to catch the cell lost fouc event of matrix.
    i want to check the value is entered the that cell, which is not greter than the extising value..
    thanks in advance......

    Hi
    For that you can use either validate or lost focus event
    Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
            ' BubbleEvent sets the behavior of SAP Business One.
            ' False means that the application will not continue processing this event.
            ' Validate event
            If (pVal.FormType = 133) And (pVal.ItemUID = 38) And (pVal.ColUID = 1) And _
              (pVal.EventType = SAPbouiCOM.BoEventTypes.et_VALIDATE) Then
                If (pVal.Before_Action) Then
                    'write your code
                End If
            End If
            'Lost focus event
            If (pVal.FormType = 133) And (pVal.ItemUID = 38) And (pVal.ColUID = 1) And _
             (pVal.EventType = SAPbouiCOM.BoEventTypes.et_LOST_FOCUS) Then
                If (pVal.Before_Action) Then
                    'write your code
                End If
            End If
        End Sub
    Hope this helps
    Regards
    Arun

  • Focus events-Help

    What would cause focus events(gain, lost) or an _inputMethodTextChanged method not to fire. I have attached these methods to both combobox controls and a text field control, put break points in the event handlers, but the events were never executed as the fields were entered or exited. Other events such as rowset populated or action events associated with a button fired.
    Thanks,
    Peter

    Laura,
    Thanks for quick replies. I tried to set the breakpoints you suggested when the addFocusListener code was called and brought me into the oracle.dacf.control.swing.comboBoxControl code, but they appeared to be ignored.
    I did find something out though. There seems to be some position dependency in the source file for the event handling method. I have been building a Frame that is divided into master-detail sections. However, I have implemented several detail panels on top of a tabbedPane control. The code has become quite long and JDev intermixes new code with old code. In trying to find out why I was not getting focus gained or lost events on a couple of comboBox controls, I also added a focus gained event handler to an existing text field.
    JDev put the event handler for the text field at the bottom of the file. I put a break point in it but it never executed. However, a separate textfield that I had earlier in the develoment process attached a focus lost event handler too was still functioning. This event handler was in the middle of the file. I decided to move the new handler to the same position. Now it too started working.
    I tried to do the same thing for the combobox handlers but they still did not work.
    Finally I added a textfield tied to the same attribute as one of the comboboxes. I also added a focus gain handler for it. JDev put the handler at the end of the file and it worked.
    So I am not sure that I am any better off than I was because I still am unsure of the real diagnosis.
    Are there any limitations on name lengths for the handlers?
    Where should the handler be relative to the declaration of the combobox?
    Out of curiosity, I just added focus-lost handlers for an old combobox and for another old textfield. The handler for the combobox did not execute but the one for the textfield did. Both were added at the end of the file.
    I am running Jdev 3.1.1.2
    Thanks,
    Peter

  • ItemEvent - Event Type - Lost Focus Event

    Hi,
    Just want to ask whether what eventtype i should use for this situation.
    I want to do something when the itemcode in marketing document been key in correctly.
    At first i use the lost focus event. but i after i find that the lost focus event will keep on check where the itemcode is key in correct or not when it lost focus. Actually I want this effect but this will caurse the scoll bar cannot move.
    For example. when i put the cursor in item code column. then i go and scoll the bar. it will keep on fire the lost focus event make me cannot scoll the bar or the matrix become wrong disappeared. Any idea on it?
    Sorry i maybe not explain well. But i don know how to explain on it. Hope you all understand what I mean la.
    Regards
    Wong

    Hi Wong
    1st Try to split them
    2nd use beforeAction=true and ItemChanged = True
    If you have 2005/2007 version on the item code et_choose_from_list and validate are similar...
    If pVal.ItemUID = "38" then
    if pVal.ColUID = "1" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_VALIDATE then
      if pVal.ItemChanged=True And pVal.BeforeAction = True then
      **** do something
      end if
    end if
    end if
    or
    If pVal.ItemUID = "38" then
    if pVal.ColUID = "1" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_choose_from_list then
      if pVal.BeforeAction = True then
      **** do something
      end if
    end if
    end if
    Regards,
    J.

  • Re:Lost focus event

    Hi all,
    I have written some code in lost focus event.But the lost focus event is not firing.i didn't set any filters.please help me to sollve my problem.
    Regards
    Mohana

    Hi,
    try this
    If pVal.ItemUid = "Uid" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_LOST_FOCUS And pVal.BeforeAction = False  and pval.charpressed=9 Then
    end if
    '9'  is the item which gets fired when tab is pressed
    it's better to write keydown if ur using tab
    and coming to firing a event i gave the code before._refere to ur previous replie's_

  • TLF lost focus event?

    Is there something like a lost focus event (like onBlur in JS)?

    It is supposed to inherit InteractiveObject events such as flash.events.FocusEvent.FOCUS_OUT ("blur" in JS)

  • The JPanel no longer gets a focus event after upgrading java version

    I have started looking at an application, which I haven't developed myself. It is a Swing application which runs as a standalone application. It is currently running on JRE 1.4.1, but for many reasons we would like to upgrade (to 1.5.0).
    During one of the actions that the users make is that he goes through a number of screens filling in details and then goes to the next screen. This has been done through having a JTabbedPane with six tabs. Each tab is a JPanel with various content.
    At each page the user presses a button, which (among other things) sets the selected Index of the JTabbedPane to the next tab. The JPanel that is attached to the tab has a FocusListener, which does various load actions when the JPanel receives focus.
    Now to the problem: In version 1.4.1 (up to and including version 1.4.1_07) these actions actually triggered the FocusListener event and ran the focusGained method as intended. Starting from 1.4.2 (and any 1.5 version I have tested) this event does not occur any longer (no code change, simply changing the JRE). My conclusion is that either the JPanel no longer gets focus or the event simply does not get triggered even though it should. What I can't figure out is why, what really happens and finally even more important, how do I solve this.
    Any help is appreciated. The code is quite extensive so it does not quite fit in here, but I will provide snippets as requested.

    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5089436
    "Evaluation" section will give you more info.
    basically, you have to set a requestFocusInWindow(), but it needs to be
    wrapped in a SwingUtilities.invokeLater(..), or, if that fails to work, inside a
    timer, setRepeats(false), about 150ms.
    From memory, it is only the timer that will work with the JTabbedPane, but
    with newer versions, the SwingUtilities.invokelater() might now work

  • [CS4/CS5] ScriptUI focus event (Win/Mac)

    Hi friends,
    I'm looking after a way to control the focus of EditText widgets within a Dialog but I'm totally confused by the event loop logics —especially in Mac OS.
    The basic task I need to achieve is to attach a validation mechanism to an EditText. When the user has entered a wrong field and the change event occurs, I want to display an alert box, then re-activate the field. The problem is that both the change event and the alert box interfer with focus attribution. I think that user or system focus/blur events are stacked so that any command that attempts to focus back to the original widget cannot work while the stack is not empty.
    Here is a simple test to illustrate my problem. The script is supposed to display an alert when the user change a field, then it tries to focus back to the corresponding field through myWidget.active = true. This does not work.
    var     u,
         w = new Window('dialog',u,u,{xname:'Window'}),
         e1 = w.add('edittext', u, "",{xname:'EditText (1)'}),
         e2 = w.add('edittext', u, "",{xname:'EditText (2)'}),
         eInfo = w.add('edittext', [0,0,300,400], "",{xname: 'EditText (Info)', multiline:true}),
         b = w.add('button',u,'Clear', {xname:'Button'});
    e1.characters = e2.characters = 20;
    var anyEvent = function(ev)
         var tg = ev.target;
         eInfo.text += (tg.properties.xname + ' -> ' +
              ev.type.toUpperCase() +
              (tg.active ? '  (active)':'  (non active)') +
              '\n');
    var changeEvent = function(ev)
         eInfo.text += ('\n--- BEFORE Breaking Alert\n');
         alert("Breaking alert");
         // Trying to FOCUS back on ev.target
         eInfo.text += ('\n--- BEFORE Active=true\n');
         ev.target.active = true;
         eInfo.text += ('--- AFTER Active=true\n');
    // Event 'inspector'
    w.addEventListener('change', anyEvent);
    w.addEventListener('focus', anyEvent);
    w.addEventListener('blur', anyEvent);
    // Events
    w.addEventListener('change', changeEvent);
    b.onClick = function(){eInfo.text = '';};
    w.show();
    I tried various strategies to address this problem by using event timestamps and/or dispatching custom new UIEvent('focus'...), but nothing works conveniently.
    In addition I got odd behaviours in Mac OS. The below screenshot shows a piece of a ScriptUI dialog —using a custom framework, so don't be surprised by the skin! What is weird is that in a particular state *two* EditText controls have the focus ring at the same time:
    I didn't know such a thing could happen. I probably did not understand anything about the 'focus' paradigm.
    Any help from an expert would be greatly appreciated. Thanks a lot!
    @+
    Marc

    Harbs. wrote:
    It does seem to change the focus, but you are still left with a cursor sometimes (which does not work).
    The one that has the focus rect allows input and .active = true seems to work fine. (Mac 10.6 CS5)
    Harbs
    Well, this is not so clear to me. My beta-tester —also Mac CS5— reports unpredictable behaviors. It also depends on how the user change the focus: using the TAB key and clicking into another field are not equivalent. (It seems that the change-focus-by-click event is more complicated to counteract...)
    But generally, on Mac platforms, we cannot be sure that setting myEditText.active = true gives the focus back to myEditText when other user events are running. The problem is that the active property is not always 'reliable'. We found that (under unstable circumstances) e1.active might returns true while e2 actually owns the focus ring! Somehow, Mac systems can dissociate the 'active' control and the focus... I don't know.
    My assumption is that the focus has a high level priority in the Mac event loop and that it closely mirrors the user interaction, while the active property is an abstract thing featured by the ScriptUI layer. The purpose of ScriptUI is to wrap OS events and widgets in a single scripting interface for both Mac and Win, but ScriptUI is nothing but a bridge. I suppose that "myWidget is active" and "myWidget has the focus" means exactly the same thing in Windows, so ScriptUI can easily target the focus through the active property in Win environment. But Mac OS doesn't work the same way.
    Interestingly when we set an EditText as borderless in Windows, we entirely remove the default widget appearence. On the contrary, a borderless EditText in Mac still reserve an additional region for the focus and there is no way to hide the focus ring when the control receives the inputs.
    In addition, I posted above a screenshot where two EditText instances have the focus ring at the same time. I'm not a Mac user but I was told that this is not a normal situation. Then playing with the active property in ScriptUI can really disrupt the focus behavior on Mac platforms...
    My first idea was to study more closely event triggering and to use a timestamp-based routine to keep the control of the focus. So I sent the following script to my beta-tester:
    var     u,
         w = new Window('dialog',u,u,{xname:'Window'}),
         e1 = w.add('edittext', u, "aaa",{xname:'(1)'}),
         e2 = w.add('edittext', u, "",{xname:'(2)'}),
         eInfo = w.add('edittext', [0,0,300,400], "",{xname: '(Info)', multiline:true}),
         cForce = w.add('checkbox', u, "Force default value on error"),
         b = w.add('button',u,'Clear', {xname:'(Button)', name:'ok'});
    e1.characters = e2.characters = 20;
    var fgTarget = null,
         fgTimeStamp = +new Date,
         fgAlerting = null,
         fgNonValid;
    var blurEventHandler = function(ev)
         if( fgAlerting ) return;
         var d = +new Date - fgTimeStamp;
         if( 100 < d )
              eInfo.text = '';
              fgTarget = ev.target;
              fgTimeStamp = +new Date;
              fgAlerting = null;
              fgNonValid = isNaN(fgTarget.text);
         d += ' ms';
         eInfo.text += (ev.target.properties.xname + ' is losing the focus  ' + d + '\n');
         fgTarget.active = true;
         if( fgNonValid )
              eInfo.text += ('  Re-activate ' + fgTarget.properties.xname +
                   ' from '+ ev.target.properties.xname + '\n' +
                   '  w.active=' + w.active + '\n' +
                   '  e1.active=' + e1.active + '\n' +
                   '  e2.active=' + e2.active + '\n') ;
              if( null===fgAlerting )
                   fgAlerting = true;
                   eInfo.text += '--- ALERT ---\n';
                   alert("Please enter a numeric value or let the field empty.");
                   fgAlerting = false;
                   if( cForce.value ) fgTarget.text = '50';
                   fgTimeStamp = +new Date;
    e1.addEventListener('blur',blurEventHandler);
    e2.addEventListener('blur',blurEventHandler);
    var anyEventHandler = function(ev)
         eInfo.text += (ev.target.properties.xname + ' -> ' + ev.type + '\n');
    e1.addEventListener('mousedown',anyEventHandler);
    e1.addEventListener('mouseup',anyEventHandler);
    e1.addEventListener('keydown',anyEventHandler);
    e1.addEventListener('keyup',anyEventHandler);
    e2.addEventListener('mousedown',anyEventHandler);
    e2.addEventListener('mouseup',anyEventHandler);
    e2.addEventListener('keydown',anyEventHandler);
    e2.addEventListener('keyup',anyEventHandler);
    b.onClick = function(){eInfo.text='';}
    e1.active = true;
    w.show();
    This script gives unstable results. ScriptUI does not always report every event that actually occurs.
    But as a general rule, what the user has done supersedes what the script can do.
    Any help from ScriptUI / Mac gurus would be highly welcome.
    @+
    Marc

  • Lost focus event litesner vs Mouse event litesner

    hi all, I having problem with JSwing components in window environment. Below is the phenomenon.
    1.) create a JFrame.
    2.) drag JTextField and JButton put onto the JFrame.
    3.) Add FocusLostEvent into the JTextField lostFocusListener.
    4.) At the event code this:-
    if (lostFocusEvent.isTemparory())
    return;
    javax.swing.JOptionPane dialog = new javax.swing.JOptionPane(
         "Error",                         javax.swing.JOptionPane.INFORMATION_MESSAGE,                         javax.swing.JOptionPane.DEFAULT_OPTION
    dialog.createDialog(this,reslabels.getString("Error_Input_Error") ).show();
    5.) run the program.
    6.) focus your cursor in the JTextField. Next, use your mouse click on the JButton.
    7.) You should see this. Message Dialog pop-up.
    8.) Well, don't click the OK/NO button from the Dialog box.
    9.) Now, point your mouse to the button and see what will happen to your JButton.
    10.) The JButton is Armed.
    By right the Jbutton should not be armed because the focus should has gained by the dialog box.
    After all, we try create the same program using MS VC++. It does not have this problem because logical enough the focus has obtained by the dialog Box. Jbutton should not perform any action. Otherwise, it is some kind of degrade the dialog show modal.
    If you has above experience and solutions, please do share with me. Thanks.
    regards,
    elvis
    scjp

    WWWizard, It doesn't work. below is the source code. Please take a look and compile it and run at your window environment.
    1.) Focus you cursor at the JTextField.
    2.) Once ready, click on the JButton. You should see the Dialog msg pop up. Do not close the Dialog at this moment.
    3.) Move your mouse pointer to the JButton that you just clicked. Why the JButton is Armed? It shouldn't happen in window environment.
    ========start==========
    package test.lib;
    import java.awt.*;
    import javax.swing.*;
    * This type was generated by a SmartGuide.
    public class TestCustLib extends JFrame {
         private JPanel ivjJFrameContentPane = null;
         private JPanel ivjTestCustLibPane = null;
         IvjEventHandler ivjEventHandler = new IvjEventHandler();
         private JTextField ivjJTextField1 = null;
         private JButton ivjJButton1 = null;
    class IvjEventHandler implements java.awt.event.FocusListener {
              public void focusGained(java.awt.event.FocusEvent e) {};
              public void focusLost(java.awt.event.FocusEvent e) {
                   if (e.getSource() == TestCustLib.this.getJTextField1())
                        connEtoC1(e);
         private lib.ButCus ivjaa = null;
    * TestCustLib constructor comment.
    public TestCustLib() {
         super();
         initialize();
    * TestCustLib constructor comment.
    * @param title java.lang.String
    public TestCustLib(String title) {
         super(title);
    * connEtoC1: (JTextField1.focus.focusLost(java.awt.event.FocusEvent) --> TestCustLib.jTextField1_FocusLost(Ljava.awt.event.FocusEvent;)V)
    * @param arg1 java.awt.event.FocusEvent
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private void connEtoC1(java.awt.event.FocusEvent arg1) {
         try {
              // user code begin {1}
              // user code end
              this.jTextField1_FocusLost(arg1);
              // user code begin {2}
              // user code end
         } catch (java.lang.Throwable ivjExc) {
              // user code begin {3}
              // user code end
              handleException(ivjExc);
    * Return the aa property value.
    * @return lib.ButCus
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private lib.ButCus getaa() {
         if (ivjaa == null) {
              try {
                   ivjaa = new lib.ButCus();
                   ivjaa.setName("aa");
                   ivjaa.setLocation(243, 160);
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjaa;
    * Return the JButton1 property value.
    * @return javax.swing.JButton
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private javax.swing.JButton getJButton1() {
         if (ivjJButton1 == null) {
              try {
                   ivjJButton1 = new javax.swing.JButton();
                   ivjJButton1.setName("JButton1");
                   ivjJButton1.setText("JButton1");
                   ivjJButton1.setBounds(60, 146, 85, 25);
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjJButton1;
    * Return the JFrameContentPane property value.
    * @return javax.swing.JPanel
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private javax.swing.JPanel getJFrameContentPane() {
         if (ivjJFrameContentPane == null) {
              try {
                   ivjJFrameContentPane = new javax.swing.JPanel();
                   ivjJFrameContentPane.setName("JFrameContentPane");
                   ivjJFrameContentPane.setLayout(new java.awt.BorderLayout());
                   getJFrameContentPane().add(getTestCustLibPane(), "Center");
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjJFrameContentPane;
    * Return the JTextField1 property value.
    * @return javax.swing.JTextField
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private javax.swing.JTextField getJTextField1() {
         if (ivjJTextField1 == null) {
              try {
                   ivjJTextField1 = new javax.swing.JTextField();
                   ivjJTextField1.setName("JTextField1");
                   ivjJTextField1.setBounds(54, 64, 126, 20);
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjJTextField1;
    * Return the TestCustLibPane property value.
    * @return javax.swing.JPanel
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private javax.swing.JPanel getTestCustLibPane() {
         if (ivjTestCustLibPane == null) {
              try {
                   ivjTestCustLibPane = new javax.swing.JPanel();
                   ivjTestCustLibPane.setName("TestCustLibPane");
                   ivjTestCustLibPane.setLayout(null);
                   getTestCustLibPane().add(getJTextField1(), getJTextField1().getName());
                   getTestCustLibPane().add(getJButton1(), getJButton1().getName());
                   getTestCustLibPane().add(getaa(), getaa().getName());
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjTestCustLibPane;
    * Called whenever the part throws an exception.
    * @param exception java.lang.Throwable
    private void handleException(java.lang.Throwable exception) {
         /* Uncomment the following lines to print uncaught exceptions to stdout */
         // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
         // exception.printStackTrace(System.out);
    * Initializes connections
    * @exception java.lang.Exception The exception description.
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private void initConnections() throws java.lang.Exception {
         // user code begin {1}
         // user code end
         getJTextField1().addFocusListener(ivjEventHandler);
    * Initialize the class.
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private void initialize() {
         try {
              // user code begin {1}
              // user code end
              setName("TestCustLib");
              setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
              setSize(460, 300);
              setTitle("TestCustLib");
              setContentPane(getJFrameContentPane());
              initConnections();
         } catch (java.lang.Throwable ivjExc) {
              handleException(ivjExc);
         // user code begin {2}
         // user code end
    * Comment
    public void jTextField1_FocusLost(java.awt.event.FocusEvent focusEvent) {
         if (focusEvent.isTemporary())
              return;
         //int li_Ok = javax.swing.JOptionPane.showConfirmDialog(this,"Don\'t click me!!! Move your mouse to JButton1.","Oops",     javax.swing.JOptionPane.DEFAULT_OPTION,javax.swing.JOptionPane.QUESTION_MESSAGE);
         javax.swing.JOptionPane.showMessageDialog(this,"Don\'t click me!!! Move your mouse to JButton1.");
         //javax.swing.JOptionPane.showInputDialog(this,"Don\'t click me!!! Move your mouse to JButton1.");
         //javax.swing.JOptionPane.showOptionDialog(this,"Don\'t click me!!! Move your mouse to JButton1.","Don\'t click me!!! Move your mouse to JButton1.",javax.swing.JOptionPane.YES_NO_OPTION,javax.swing.JOptionPane.WARNING_MESSAGE,null,null,null);
         //javax.swing.JOptionPane.showInternalMessageDialog(null,"ta");
         return;
    * Starts the application.
    * @param args an array of command-line arguments
    public static void main(java.lang.String[] args) {
         try {
              /* Set native look and feel */
              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              /* Create the frame */
              TestCustLib aTestCustLib = new TestCustLib();
              /* Add a windowListener for the windowClosedEvent */
              aTestCustLib.addWindowListener(new java.awt.event.WindowAdapter() {
                   public void windowClosed(java.awt.event.WindowEvent e) {
                        System.exit(0);
              aTestCustLib.setVisible(true);
         } catch (Throwable exception) {
              System.err.println("Exception occurred in main() of TestCustLib");
              exception.printStackTrace(System.out);
    ========end==========

Maybe you are looking for

  • How to schedule dependent job in oracle

    I would like to schedule a job which should be dependent on the completion of previous job. How is it achieved in oracle 10g

  • % of load on system in SE30

    Hi,   I have made a  ZREPORT  while performance checking in SE30  some same report with same input parameters  if i execute the report diffrent time  it is showing  diffretn graph with % of load ,  some time  on the system it is showing  4 % load   a

  • How to use VS2005 dlls with jni?

    Hello, I have a java application using jni and some dlls. Previously this dlls were created using VS2003. Now I want to use VS2005 and I encountered some problems. Everything is working on my station were I have installed VS2005 but when I try to run

  • How to work with 50i and 30f/p footage at the same time - FCPX XHA1s

    Hi all, Brand new to iMac and FCPX... so really hoping for some help from the more experienced out there! I've been shooting in 50i on my XHA1s for about a year, but have faced lots of interlacing issues which I've never managed to resolve. I didn't

  • What is best way to transfer files from my g5 to my macbook

    I'm giving my G5 away and need to remove email accounts from G5. I thought I'd done it last night but it turns out I'd deleted all emails from G5 therefore Cloud, Mobile Me and iphone. I bought the G5 first and that pushes to Mobile Me and MacBook. S