I’ve several component put together with the Jucer. I noticed that the mouseEnter calls are ‘disabled’ while I’m dragging from another component. IE : I drag out from component A, and I want component B to be send a mouseEnter notification when the mouse enter it, but I can’t get anything.
I would like the component to interacts each others while dragging, so what is the best way to do so ?
Yes, you always want the comp that’s being dragged to receive the messages until the mouse is released. But it’s simple to make that component do the appropriate thing based on which other comp the mouse is over, or use the DragAndDropTarget classes to do it for you.
are you just talking about dragging the mouse from one component to another, or are you talking about dragging a component from one to another? [because if its the latter, then the mouse will always be over the component that is being dragged]
Yes, however in this (A) mouseDrag callback, how do I know which of the (B) component is draged over ? And then how is it possible to ‘inform’ B that it is beeing dragged over without using a timer inside B ?
ha! your response doesn’t quite answer the question…
Q: Is it type [A] from one to another or type [B] from one to another?
A: Yes, from one to another.
I’m going to assume that you mean version A (where you’re not dragging anything, just the mouse).
there’s Component::getComponentUnderMouse() which will return the component currently under the mouse, if you haven’t tried that yet it could be what you’re after. Using timers to do this will only upset you later down the line, as it’s a bodge and a half.
Apologies for re-invoking such an old post, but I’m having a very similar issue:
I have a row of buttons that, in between mouseDown and mouseUp events, repaint the button that the mouse is currently over. I do this by calling repaint() in the mouseDrag function. The problem is that getComponentUnderMouse() always returns the Component where the event was sent from:
void MyButton::mouseDrag(const MouseEvent& e)
MyButton* c = dynamic_cast<MyButton*> (e.source.getComponentUnderMouse());
if(c && c != this)
c->repaint(); // never called, as c is always this.
Does the MouseInputSource ‘source’ only pertain to the origin of the mouse event? If so, how do I modify MouseInputSource, such that getComponentUnderMouse() returns the Component that the mouse is actually under?