<AWT Dev> <AWT dev>[9] Review request for JDK-8155740: [macosx] robot.keyPress and robot.keyRelease do not generate key event for Alt-Graph key VK_ALT_GRAPH.

Manajit Halder manajit.halder at oracle.com
Thu May 19 17:40:36 UTC 2016


Hi Semyon,

Gentle reminder. Please review the changes.

Regards,
Manajit

> On 14-May-2016, at 2:20 am, Manajit Halder <manajit.halder at oracle.com> wrote:
> 
> Hi Semyon,
> 
> The fix is changed a bit because it was observed that the modifier keys plus alphabet keys were not working together. In the modified fix only Num keys are posted by AXUIElementPostKeyboardEvent and remaining keys are posted by CGPostKeyboardEvent/CGEventPost. The fix is explained in the comment in file CRobot.m.
> 
> Please review the new changes:
> http://cr.openjdk.java.net/~mhalder/8155740/webrev.01/ <http://cr.openjdk.java.net/~mhalder/8155740/webrev.01/>
> 
> 
> Answers to your questions:
> 
> What is difference between AXUIElementPostKeyboardEvent and CGEventCreateKeyboardEvent?
> 
> Difference as per the documentation:
> 	AXUIElementPostKeyboardEvent is similar to CGPostKeyboardEvent (which synthesizes a low-level keyboard event on the local machine), but it allows you to specify the target application as opposed to always sending the events to the active application. If the system-wide accessibility object is passed in the application parameter, the event is sent to the active application. 
> 
> Difference behaviour as per the implementation observed while debugging the code:
> 	
> AXUIElementPostKeyboardEvent:
> 	AXUIElementPostKeyboardEvent posts 0 key code for all the modifier keys with key codes 16, 17,18, 20, 157 and also for newly added modifier key VK_ALT_GRAPH. But it posts correct key code for all the remaining keys.
> 	While debugging it was that for modifier keys keyDown and keyUp events are not generated, but flagsChanged event (flagsChanged: (NSEvent *)event) is generated. But for all other keys keyDown followed by keyUp events are generated.
> 
> CGEventCreateKeyboardEvent:
> 	CGEventCreateKeyboardEvent posts correct key code for all the keys except for numeric keys (numbers 0 to 9 on normal keyboard). CGEventCreateKeyboardEvent posts wrong key codes for the number keys 0 to 9. Instead of posting number key codes it posts Numpad key codes for the corresponding number key. For example Numpad0 key code is posted for number 0, Numpad1 key code is posted for number 1 and simillarly for remaining num keys.
> 	
> Why the latter was commented? Does it mean that valid modifier keys have not been sent by AWT robot?
> 
> I didn’t get your question clearly. If you meant why in the current implementation the later part (fix using CGPostKeyboardEvent) of fix was commented.
> 	I am not very sure about it. As per the comment it is only clear that CGPostKeyboardEvent/CGEventPost would have been a better solution and I agree with that, perhaps reason could be related to the difference in behaviour observed while debugging the code as mentioned above.
> 
> Thanks,
> Manajit
> 
>> Hi Manajit,
>> 
>> Just a few questions to clarify on the fix.
>> What is difference between AXUIElementPostKeyboardEvent and CGEventCreateKeyboardEvent?
> 	
>> Why the latter was commented? Does it mean that valid modifier keys have not been sent by AWT robot?
>> 
>> --Semyon
>> 
>> 
>> On 5/12/2016 10:45 AM, Manajit Halder wrote:
>>> Hi All,
>>> 
>>> Kindly review the fix for JDK9.
>>> 
>>> Bug: 
>>> https://bugs.openjdk.java.net/browse/JDK-8155740 <https://bugs.openjdk.java.net/browse/JDK-8155740>
>>> 
>>> Webrev: 
>>> http://cr.openjdk.java.net/~mhalder/8155740/webrev.00/ <http://cr.openjdk.java.net/%7Emhalder/8155740/webrev.00/>
>>> 
>>> Issue: 
>>> [macosx] robot.keyPress and robot.keyRelease do not generate key event for Alt-Graph key VK_ALT_GRAPH.
>>> 
>>> Cause: 
>>> VK_ALT_GRAPH is a new key added to the Mac OS X platform and it is not mapped to any key on the OS X platform.
>>> 
>>> Fix: 
>>> VK_ALT_GRAPH is mapped to right option (OSX_RightOption) key on Mac OS X.
>>> 
>>> Method Java_sun_lwawt_macosx_CRobot_keyEvent is modified for the following reason:
>>> AXUIElementPostKeyboardEvent posts 0 key code for all  the modifier keys with key codes (16, 17,18, 20, 157) and also for newly added modifier key VK_ALT_GRAPH.
>>> But it posts correct key code for all the other keys. On the other hand CGEventCreateKeyboardEvent posts correct key code for all the modifier keys and 
>>> hence it is used to post modifier key events and AXUIElementPostKeyboardEvent is used to post all the remaining key events.
>>> 
>>> Regards,
>>> Manajit
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20160519/c4582316/attachment.html>


More information about the awt-dev mailing list