This discussion is archived
0 Replies Latest reply: Oct 30, 2012 5:03 AM by 922905 RSS

Key event handling after drag & drop in Jdk1.7.0_09 under OS X 10.8.2

922905 Newbie
Currently Being Moderated
Perhaps someone can help, but I think it is a bug.
We have developed a big Java application (more then 1000 classes), that behaves strange on Mac OS X 10.8.2 with installed Jdk1.7.0_09.
The main problem is, that after performing a drag&drop no key event is delivered to the installed KeyListeners.

I implemented some System.out.println() in the program, to get response of key events (only for key "N" as representaive) .
There are 3 listeners implements represented by the numbers behind the key event:
2 -> ClassMaker addKeyListener
3 -> ClassMaker KeyEventDispatcher()
4     -> ContentPane Page addKeyListener

Next following is a list of actions done and the corresponding events received in the left part for windows and mac.



Jdk1.7.0_09 CW Standalone Windows 7 32 Bit behaves ok
==========================================

N key pressed 3                                        
Page N key pressed 4                                   
N key pressed 2                                             
dragGestureRecognized...                              
dragGestureRecognized MOVE_LAYER                    
N key pressed 3                                        
Page N key pressed 4                                   
N key pressed 2                                             
N key pressed 3                                             
Page N key pressed 4                                   
N key pressed 2                                             
drop....                                                  
drop MOVE_LAYER                                        
drop N key pressed: true                              
mouseWasReleased _fixmove: false                                
N key pressed 3                                             
N key pressed 3                                             
N key pressed 3                                             
N key released 3                                        
N key pressed 3                                             
N key released 3                                        

Under Mindows 7 32 Bit with installed Jdk1.7.0_09 key events are not blocked after drag&drop, although only one of the listeners (number 3) gets key events, everything works ok so far.

Jdk1.7.0_09 CW Webstart Mac OSX 10 errors in event handling !!!!!!!!
=====================================

N key pressed 3                                             
Page N key pressed 4                                   
N key pressed 2                                             
dragGestureRecognized...                              
dragGestureRecognized MOVE_LAYER                    
drop....                                                  
drop MOVE_LAYER                                        
drop N key pressed: true                              
mouseWasReleased _fixmove: false                                 

Under OS X 10.8.2 with installed Jdk1.7.0_09 key events are blocked after drag&drop. None of the listeners gets any key event, not for pressed key and not for released key,
no matter how often N key is pressed or released.

Thanks for looking
Heribert

After testing a lot, I found out, that there is more then 1 bug with the key event management.

after adding a KeyListener and pressing a key (N) for 1 second I get totally different results for windows and mac
Under Windows Jdk1.7.0_09 and by the way under windows Jdk1.6.0_17 and also under Mac OS X Jdk1.6.0_37 the
pressing the key (N) for 1 second delivers the following response:

N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key pressed 3
Page N key pressed 4
N key pressed 2
N key released 3
Page N key released 4
N key released 2

That means as long as the key is pressed key events are incoming in the KeyListener (about 20 in 1 second)

Under Mac OS X 10.8 Jdk1.7.0_09 I get this:

N key pressed 3
Page N key pressed 4
N key pressed 2
N key released 3
Page N key released 4
N key released 2

Only one key event comes in for key pressed, and one for key released, although the key is pressed for 1 second. I think this is a bug too.

This let behave our program very strange and is one of the reasons why the behaviour described in the beginning of this message happens.
Why?
The problem with the key events and drag&drop is, that key events are not passed to any KeyListener, as long as drag&drop is active.
This leads to the problem, that the order of actions: first release the key, second release the mouse button delivers no key release event to the listener.
On the other hand the order of actions: first release the mouse, second release the key delivers a key event to the KeyListener.

To get a acceptable behaviour of the program, I implemented, that a mouse release event also resets all key pressed actions. This worked nearly perfect for 7 years,
because a next drag&drop without releasing the key gets the information, that the key is pressed, because key events are fired by the system,as long as the key
is pressed. But this solution does not work under Jdk1.7.0_09 on Mac OS X 10.8 because only 1 key event was fired at the time, when the key was pressed
and not all the time as long as the key is pressed.

I hope someone understood my problem.

Heribert

Edited by: 919902 on 30.10.2012 04:30

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points