From aa27a098017502f1bc9817b6530d41284e936e74 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Tue, 4 Mar 2014 17:56:41 +0100 Subject: [PATCH] MouseEvent: comply with DOM Level 3 and add some getter. --- simgear/canvas/MouseEvent.hxx | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/simgear/canvas/MouseEvent.hxx b/simgear/canvas/MouseEvent.hxx index f6faee76..182115a1 100644 --- a/simgear/canvas/MouseEvent.hxx +++ b/simgear/canvas/MouseEvent.hxx @@ -32,19 +32,24 @@ namespace canvas { public: MouseEvent(): - button(-1), - state(-1), - mod(-1), + button(0), + buttons(0), + modifiers(0), click_count(0) {} MouseEvent(const osgGA::GUIEventAdapter& ea): - button(ea.getButton()), - state(ea.getButtonMask()), - mod(ea.getModKeyMask()), + button(0), + buttons(ea.getButtonMask()), + modifiers(ea.getModKeyMask()), click_count(0) { time = ea.getTime(); + + // Convert button mask to index + int button_mask = ea.getButton(); + while( (button_mask >>= 1) > 0 ) + button += 1; } osg::Vec2f getScreenPos() const { return screen_pos; } @@ -64,6 +69,10 @@ namespace canvas float getDeltaX() const { return delta.x(); } float getDeltaY() const { return delta.y(); } + int getButton() const { return button; } + int getButtonMask() const { return buttons; } + int getModifiers() const { return modifiers; } + int getCurrentClickCount() const { return click_count; } osg::Vec2f screen_pos, //