Form Roland Smeenk, "Attached is a small change to the osgWidget::EventInterface so it matches the NotifyWidget and NullWidget interface (added const). Due to this mismatch these widgets never received events.
I also changed the osgwidgetbox example so the ColorWidget is receiving events again."
This commit is contained in:
@@ -18,9 +18,10 @@ const unsigned int MASK_3D = 0x0F000000;
|
||||
struct ColorWidget: public osgWidget::Widget {
|
||||
ColorWidget():
|
||||
osgWidget::Widget("", 256.0f, 256.0f) {
|
||||
setEventMask(osgWidget::EVENT_ALL);
|
||||
}
|
||||
|
||||
bool mouseEnter(double, double, osgWidget::WindowManager*) {
|
||||
bool mouseEnter(double, double, const osgWidget::WindowManager*) {
|
||||
addColor(-osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f));
|
||||
|
||||
// osgWidget::warn() << "enter: " << getColor() << std::endl;
|
||||
@@ -28,7 +29,7 @@ struct ColorWidget: public osgWidget::Widget {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mouseLeave(double, double, osgWidget::WindowManager*) {
|
||||
bool mouseLeave(double, double, const osgWidget::WindowManager*) {
|
||||
addColor(osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f));
|
||||
|
||||
// osgWidget::warn() << "leave: " << getColor() << std::endl;
|
||||
@@ -36,7 +37,7 @@ struct ColorWidget: public osgWidget::Widget {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mouseOver(double x, double y, osgWidget::WindowManager*) {
|
||||
bool mouseOver(double x, double y, const osgWidget::WindowManager*) {
|
||||
osgWidget::Color c = getImageColorAtPointerXY(x, y);
|
||||
|
||||
if(c.a() < 0.001f) {
|
||||
|
||||
@@ -277,22 +277,22 @@ class OSGWIDGET_EXPORT EventInterface
|
||||
// Notify the EventInterface object that is has been focused or unfocused; since
|
||||
// this isn't always bound to a mouse event (i.e., if you want to be able to use
|
||||
// the TAB key to focus), we need seperate events here.
|
||||
virtual bool focus (WindowManager*) { return false; }
|
||||
virtual bool unfocus (WindowManager*) { return false; }
|
||||
virtual bool focus (const WindowManager*) { return false; }
|
||||
virtual bool unfocus (const WindowManager*) { return false; }
|
||||
|
||||
// Mouse events, pretty self-explanatory.
|
||||
virtual bool mouseEnter (double, double, WindowManager*) { return false; }
|
||||
virtual bool mouseOver (double, double, WindowManager*) { return false; }
|
||||
virtual bool mouseLeave (double, double, WindowManager*) { return false; }
|
||||
virtual bool mouseDrag (double, double, WindowManager*) { return false; }
|
||||
virtual bool mousePush (double, double, WindowManager*) { return false; }
|
||||
virtual bool mouseRelease (double, double, WindowManager*) { return false; }
|
||||
virtual bool mouseScroll (double, double, WindowManager*) { return false; }
|
||||
virtual bool mouseEnter (double, double, const WindowManager*) { return false; }
|
||||
virtual bool mouseOver (double, double, const WindowManager*) { return false; }
|
||||
virtual bool mouseLeave (double, double, const WindowManager*) { return false; }
|
||||
virtual bool mouseDrag (double, double, const WindowManager*) { return false; }
|
||||
virtual bool mousePush (double, double, const WindowManager*) { return false; }
|
||||
virtual bool mouseRelease (double, double, const WindowManager*) { return false; }
|
||||
virtual bool mouseScroll (double, double, const WindowManager*) { return false; }
|
||||
|
||||
// These functions pass the osgGA::GUIEventAdapter::KeySymbol and KeyModMask and,
|
||||
// as above, the WindowManager.
|
||||
virtual bool keyDown (int, int, WindowManager*) { return false; }
|
||||
virtual bool keyUp (int, int, WindowManager*) { return false; }
|
||||
virtual bool keyDown (int, int, const WindowManager*) { return false; }
|
||||
virtual bool keyUp (int, int, const WindowManager*) { return false; }
|
||||
|
||||
void setEventMask(unsigned int mask) {
|
||||
_eventMask = mask;
|
||||
|
||||
Reference in New Issue
Block a user