Donj Nicolas-Nombre
Donj Nicolas-Nombre

Reputation: 1

add AWT listener to SWT component

Is there a way to add AWT listener to a SWT component?

I previously made an app running mostly in AWT and Swing components. Now, I have hotkeys function which is dependent on a custom-made library that listens to global key events and returns its corresponding AWT key code.

My problem arises when I shifted the whole app and used SWT components instead. As we know some of the keys returns a different key code now, which messes up the whole hotkeys function.

The initial solutions I've thought of are:

A. Use javax.swing.jtextfield as mycomponent listener instead of swt.widget.text

B. Add AWT listener to SWT component (if possible)

C. Create a class which re-maps all AWT keycodes to SWT and vice-versa.

I believe these are feasible solutions. I just want to check out with you guys if you have a brilliant idea on which I could work with. I'm only new to java and I could use some professional insights on this.

(besides, I think A is cheating. B I could not find a way to do yet. And C is a hassle job to do)

Cheers.

Upvotes: 0

Views: 231

Answers (1)

Sorceror
Sorceror

Reputation: 4843

After some googling I've found class from JBoss Tools which might help you with mapping from AWT keycodes to SWT one's..

See KeyboardHelper class from JaCoCo project.

Upvotes: 0

Related Questions