The mouseOverAction must be allowed in the View instance.
Please refer to http://doc.sccode.org/Classes/View.html
and find .acceptsMouseOver
(
var win = View()
.acceptsMouseOver_(true)
.layout_(HLayout().spacing_(1).margins_(1))
.minWidth_(300)
.minHeight_(200);
var w1 = UserView()
.maxWidth_(100)
.maxHeight_(100)
.drawFunc_{ arg view;
Pen.fillRect(Rect(0, 0, 100, 100));
}
.mouseOverAction_{ arg view, x, y;
"w1".postln;
};
var w2 = UserView()
.mouseUpAction_{ arg view, x, y, modifiers, buttonNumber;
"w2".postln;
}
.maxWidth_(100)
.maxHeight_(100)
.drawFunc_({arg view;
Pen.fillRect(Rect(0, 0, 100, 100));
});
win.layout.add(w1);
win.layout.add(w2);
win.front;
)
You may need the position of mouse pointer and others as follows:
(
var win = View()
.acceptsMouseOver_(true)
.layout_(HLayout().spacing_(1).margins_(1))
.minWidth_(300)
.minHeight_(200);
var w1 = UserView()
.maxWidth_(100)
.maxHeight_(100)
.drawFunc_{ arg view;
Pen.fillRect(Rect(0, 0, 100, 100));
}
.mouseOverAction_{ arg view, x, y;
[view, "w1", x, y].postln;
};
var w2 = UserView()
.mouseUpAction_{ arg view, x, y, modifiers, buttonNumber;
[view, "w2", x, y, modifiers, buttonNumber].postln;
}
.maxWidth_(100)
.maxHeight_(100)
.drawFunc_({arg view;
Pen.fillRect(Rect(0, 0, 100, 100));
});
win.layout.add(w1);
win.layout.add(w2);
win.front;
)
One more thing:
the quotation marks in your code are not the quotation marks used in sclang.
“w2”.postln; // this is your code, and this is not correctly accepted by sclang.
"w2".postln; // this is accepted correctly by sclang.