Hi folks
If you run the following code:
(
~childViews = List();
~addChildView = {
|child|
~childViews.add(Dictionary.newFrom([\view, child, \originalBounds, child.bounds]););
};
~resizeChildren = {
|scale|
~childViews.do({
|child|
child[\view].bounds = Rect(child[\originalBounds].left*scale,child[\originalBounds].top*scale,child[\originalBounds].width*scale,child[\originalBounds].height*scale);
});
};
~window = Window("Zooming and scrolling", Rect(50,50,800,600));
~scale = 1.0;
~originalHeight = 100;
~originalWidth = 100;
~zoomme = View(~window, Rect(50, 50, ~originalWidth, ~originalHeight)).background_(Color.black)
.mouseWheelAction_({
|view, x, y, modifiers, xDelta, yDelta|
//[view, x, y, modifiers, xDelta, yDelta].postln;
~scale = ~scale * 1 + (yDelta*0.005);
postln(format("scale: %", ~scale));
~zoomme.resizeTo(~originalWidth * ~scale, ~originalHeight * ~scale);
~resizeChildren.value(~scale);
}).mouseDownAction_({postln("I'm black!")});
~addChildView.value(View(~zoomme,Rect(10,40,20,20)).background_(Color.red).mouseDownAction_(postln("I'm red!")));
~addChildView.value(View(~zoomme,Rect(40,20,20,20)).background_(Color.blue).mouseDownAction_(postln("I'm blue!")));
~addChildView.value(View(~zoomme,Rect(70,40,20,20)).background_(Color.green).mouseDownAction_(postln("I'm green!")));
~window.front;
)
… you will see that if you click on one of the coloured boxes, the event is handled by the parent black box, but if you mouse wheel over one of the coloured boxes, that event is not handled by the parent black box. This is in fact the exact opposite of what I want. ![]()
How do I get the click events to be handled by the coloured boxes, while any mouse wheel event is always handled by the parent black box?