Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Making Controls out of existing native components

Hello,

A coworker came up with an interesting problem. We are embedding a natively-created HIView into an SWT Canvas. Our HIView displays but doesn't receive mouse or key events because the SWT doesn't deliver events to HIViewRefs that it doesn't know about (i.e., that it created.)

The solution should be this: Create a subclass of Control that takes an int as a parameter, where the int is the handle to the pre-created native object. Instances of this subclass own the native control passed in at creation time, and will dispose of it when disposed. createHandle() is overridden to just stuff the int passed in at creation time into the 'handle', and then it gets registered with Display, and hookEvents() hangs the OS event handlers on the control.

Is it okay to subclass Control in this way? createHandle() is package private, so I don't see a good way to do this cleanly without putting the class in the SWT package. I'd like to avoid that if possible.

Scott

------------------
Scott Kovatch
Cupertino, CA




Back to the top