<AWT Dev> creating an ActionEvent with modifiers from an InputEvent
Sergey Bylokhov
Sergey.Bylokhov at oracle.com
Thu Apr 11 02:32:09 UTC 2019
Hi, Alan.
> That sounds promising, but there are backward compatibility issues. Can you be more specific?
I think that on some platforms we already set the InputEvent.modifiers when we create the ActionEvent, so the mask in such ActionEvent contains bits related to both: InputEvent and ActionEvent:
http://hg.openjdk.java.net/jdk/jdk/file/96230a5ef2ec/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp#l2685
Not sure it was done unintentionally, but probably we can accept such implementation and specify it.
I suggest to create a CR to investigate this case.
>
> Alan
>
>
>
>
>> On Oct 29, 2018, at 12:38 PM, Sergey Bylokhov <Sergey.Bylokhov at oracle.com> wrote:
>>
>> Hi, Alan.
>> I think that a better alternative is to deprecate these constans in the ActionEvent and reuse the new constants from the InputEvent, conversion might be done in the constructor of ActionEvent.
>>
>> On 28/10/2018 13:33, Alan Snyder wrote:
>>> ActionEvent defines four modifier bits for SHIFT, CTRL, META, and ALT that coincidentally (not really, but distinct static variables are used, so how would one know for sure?) match modifier bits defined by InputEvent/Event. Oddly, the latter modifier bits were deprecated in JDK 9, as was the method to fetch them.
>>> So, what is the correct way to create an ActionEvent with modifier bits extracted from an InputEvent?
>>> There are many examples in the JDK where this is done, and they all use the deprecated method InputEvent.getModifiers().
>>> Is there a recommended alternative?
>>
>>
>> --
>> Best regards, Sergey.
>>
>
--
Best regards, Sergey.
More information about the awt-dev
mailing list