<AWT Dev> creating an ActionEvent with modifiers from an InputEvent

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

<AWT Dev> creating an ActionEvent with modifiers from an InputEvent

Alan Snyder-3
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?



Reply | Threaded
Open this post in threaded view
|

Re: <AWT Dev> creating an ActionEvent with modifiers from an InputEvent

Denis Fokin
Hi Alan,

according to the new JavaDoc "It is recommended that extended modifier keys and getModifiersEx() be used instead". Does this method suit your needs?

Thank you,
    Denis

On Sun, Oct 28, 2018 at 11:33 PM Alan Snyder <[hidden email]> 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?



Reply | Threaded
Open this post in threaded view
|

Re: <AWT Dev> creating an ActionEvent with modifiers from an InputEvent

Alan Snyder-3
No, that would require ActionEvent to accept extended modifiers.

On Oct 29, 2018, at 3:03 AM, Denis Fokin <[hidden email]> wrote:

Hi Alan,

according to the new JavaDoc "It is recommended that extended modifier keys and getModifiersEx() be used instead". Does this method suit your needs?

Thank you,
    Denis

On Sun, Oct 28, 2018 at 11:33 PM Alan Snyder <[hidden email]> 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?




Reply | Threaded
Open this post in threaded view
|

Re: <AWT Dev> creating an ActionEvent with modifiers from an InputEvent

Sergey Bylokhov
In reply to this post by Alan Snyder-3
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.
Reply | Threaded
Open this post in threaded view
|

Re: <AWT Dev> creating an ActionEvent with modifiers from an InputEvent

Alan Snyder-3
Hi Sergey,

That sounds promising, but there are backward compatibility issues. Can you be more specific?

  Alan




> On Oct 29, 2018, at 12:38 PM, Sergey Bylokhov <[hidden email]> 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.
>