That idea sounds very good. the problem with multiple listeners is that you have to manage a bunch of states so that those not really interested in the event ignore it.
One of the things i’ve had trouble with is changing the ModifierKeys. my previous hack of calling the private
internalMouseDown' method has now been abandoned. I did this because i had an additional MouseListener on my component. I later ran into a problem where i had to, effectively, turn mouseDown into a mouseUp. There was no way to convince the internal mouse source of this. So in the end, i rewrote a lot of my code to avoid needing a second MouseListener and now i call the componentmouseDown’ (etc) directly, as in my original approach. Naturally, this will only work in a limited way. There is still the problem, however, that I have to call mouseDown during the `mouseUp’ handler of a parent component.
MouseEvent de = e.getEventRelativeTo(c);
// XXX Nasty HACK!
ModifierKeys* kp = (ModifierKeys*)&de.mods;
*kp = ModifierKeys(ModifierKeys::leftButtonModifier);
All this comes about, as you’ve mentioned, when trying to integrate gestures and mouse events. Since gestures come through as mouse events, you get situations where you have to “translate” them. One of the things im trying to do is make an interface that works on both desktop and mobiles, so that something that might be a right mouse button on the desktop will be a gesture on the mobile, or perhaps activated by a long tap which then enters a state where i have to reinterpret subsequent mouse events.
Another annoyance is keyboard focus. Juce is designed to try to assign focus with clicks. However, on mobiles whenever there’s a keyboard focus, a giant keyboard pops and covers half the screen. This keyboard winds up flapping up and down in a comedy way as you touch things. So what i had to do is assign keyboard focus in a more specific way to components within my parent canvas. Its turns out the means to do this totally manually is possible in Juce, but you have to
setMouseClickGrabsKeyboardFocus' to false, then managewantKeyboardFocus’ dynamically and call `grabKeyboardFocus’ as required. Unfortunately, there’s no way to discard the keyboard focus, so you have to have a bogus component to assign it to. So i’ve got the key focus sorted.