Intercepting mouse events on FileBrowserComponent


#1

Hi all,
I’m making some experiments with Juce’s Components.
I have the following class

class MyComponent : public Component{

public :
MyComponent(Component * comp){
    this->child = comp;
    comp->setInterceptsMouseClicks(false, false);

}
void mouseDown (const MouseEvent &e){

   //do stuff
   Component *target = getTopChild(this->child, e.x, e.y);   //return top most component of child that would have intercept the mouse event if that wasn't intercepted by MyComponent class
   if (target != NULL && doIWantToForwardEventToTarget()){
        MouseEvent newEvent = e.getEventRelativeTo(target);
        target->mouseDown(newEvent);
   }
}
void mouseMove (const MouseEvent &e);
void mouseEnter (const MouseEvent &e);
void mouseExit (const MouseEvent &e);
void mouseDrag (const MouseEvent &e);
void mouseUp (const MouseEvent &e);
void mouseDoubleClick (const MouseEvent &e);
void mouseWheelMove (const MouseEvent &e, float wheelIncrementX, float wheelIncrementY);

private:

Component *child;
}

The purposes of this class are:

1- store a single Component of a hierarchy of Components (child)
2- intercept all mouse events related to child or one of its descendant
3- do something
4- eventually forward the mouseevent to the Component which it was directed to

I tried this class with sliders components as children, even nested inside other components… all works fine.
Now I was doing some experiments with FileBrowserComponent and it seems not to work properly. For example when I click on the button to move to the upside directory it doesn’t (the button receives the mouse event and it’s clicked but nothing happen in the tree view).
Also selecting items from the list doesn’t work.

What could be the problem?
(I did some experiments and seems that the method buttonClicked in the FileBrowserComponent isn’t called, but I dont’t know why)
Any suggestion?

thanks in advance

EDIT:

I get no answer, but I’m still trying to solve this problem.
I modified the code this way:

void mouseDown (const MouseEvent &e){

   //do stuff
   Component *target = getTopChild(this->child, e.x, e.y);   //return top most component of child that would have intercept the mouse event if that wasn't intercepted by MyComponent class
   if (target != NULL && doIWantToForwardEventToTarget()){
        target->setInterceptsMouseClicks(true, true);
        MouseEvent newEvent = e.getEventRelativeTo(target);
        target->mouseDown(newEvent);
        target->setInterceptsMouseClicks(false, false);
   }
}

It still doesn’t work. Anyway I found out that if I comment the second call to setInterceptMouseClicks( where I disable the mouse click after ) make the things work (even if this isn’t the result I’d want to obtain because I need to redisable mouse events on that component).

These facts can led me to 2 considerations:
[list]
1- A component need to intercept mouse clicks even if mouse events are manually passed to its mouseDown method (is this true? I’m not so sure about that)
2- After the mouse event handling in FileBrowserComponent there are other classes that uses the information of its intercepting mouse click status, otherwise it would work if after the target->mouseDown(newEvent), I’ll disable mouse clicks again. Any idea?
[/list]


#2

Nobody?