Hi,
I’m new to Juce, and I’m looking for the right way to add
a Juce component in a native window (in a existing C application),
or to paint the component inside this window
(that use Quickdraw).
Any help/example/suggestion will be appreciated
Best Regards
Riccardo
That’s always a tough thing to try to do - best thing would be to look at the juce plugin code, where it uses various tricks to embed juce comps in different types of host.
That’s a thought, making a juce class that can accept a current native window in its constructor so it can wrap things enough to let other juce components go inside? And/or vice-versa?
I’ve trying to do the same thing and quite struggle a bit.
I’m working on Mac/PC Audio Plugin but already have a fully working and quite powerful plugin framework, so using JAP is quite out of question.
(it already supports AU, VST, MAS, RTAS, StandAlone, DX)
I’m currently evaluating JUCE as a possible replacement for our inhouse GUI toolkit.
After digging into JAP it seems that there is still some stuff like SetParent or mac equivalent which are still in each plugin system wrapper.
I was wondering if there was a possibility to hide into a class like ComponentWrapper all the native stuff to embed a Component into an existing native window, so JUCE would be more easily pluggable into a plugin environment.
Hmm, it’s not as simple as that, unfortunately - all the plugin formats are a bit quirky and have specialised code, so I don’t think there’d be very much commonality between them. Whatever I could find that was common I added to the peer classes.
The first problem was with mouse interaction: when the mouse pass over the component the application stop to listen mouse events
(like as the component takes and don’t release mouse events):
I solved this problem adding at the end of handleMouseEvent (in juce_mac_windowing.cpp)
the following line:
CallNextEventHandler(callRef, theEvent);
A second problem was to be able to click on and receive mouse notification in the component.
The only solution I founded was to change the following line in Component::getComponentAt (juce_Component.cpp)
from
if (flags.visibleFlag && x >= 0 && y >= 0 && x < compW_ && y < compH_ && hitTest (x, y))
to
if (flags.visibleFlag && x >= 0 && y >= 0 && x < compX_ + compW_ && y < compY_ + compH_ && hitTest (x, y))
Now my component receives mouseDown/ mouseMove/ mouseEnter/ mouseExtit but not mouseDrag and mouseUp (why?)
I need also that when the component receives a mouse event then pass it to the application and other listeners.
Do you have an idea if it is possible and how to do that?