From: Thomas Geymayer Date: Thu, 6 Dec 2012 22:27:25 +0000 (+0100) Subject: Canvas add event time and expose current click count X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=91bc5e522a5feda140dac257022c0eb250b4950e;p=flightgear.git Canvas add event time and expose current click count --- diff --git a/src/Canvas/gui_mgr.cxx b/src/Canvas/gui_mgr.cxx index 02d8073c7..cf5a047b0 100644 --- a/src/Canvas/gui_mgr.cxx +++ b/src/Canvas/gui_mgr.cxx @@ -259,6 +259,7 @@ bool GUIMgr::handleMouse(const osgGA::GUIEventAdapter& ea) namespace sc = simgear::canvas; sc::MouseEventPtr event(new sc::MouseEvent); + event->time = ea.getTime(); event->pos.x() = 0.5 * (ea.getXnormalized() + 1) * _width + 0.5; event->pos.y() = 0.5 * (ea.getYnormalized() + 1) * _height + 0.5; diff --git a/src/GUI/CanvasWidget.cxx b/src/GUI/CanvasWidget.cxx index fe0119db5..bbbecd55e 100644 --- a/src/GUI/CanvasWidget.cxx +++ b/src/GUI/CanvasWidget.cxx @@ -18,6 +18,8 @@ #include #include +SGPropertyNode_ptr CanvasWidget::_time; + //------------------------------------------------------------------------------ CanvasWidget::CanvasWidget( int x, int y, int width, int height, @@ -113,6 +115,11 @@ void CanvasWidget::doHit(int button, int updown, int x, int y) namespace sc = simgear::canvas; sc::MouseEventPtr event(new sc::MouseEvent); + + if( !_time ) + _time = globals->get_props()->getNode("/sim/time/elapsed-sec"); + event->time = _time->getDoubleValue(); + event->pos.set(x - abox.min[0], abox.max[1] - y); event->delta.set( event->pos.x() - _last_x, event->pos.y() - _last_y ); diff --git a/src/GUI/CanvasWidget.hxx b/src/GUI/CanvasWidget.hxx index f5fa0bf75..403523b25 100644 --- a/src/GUI/CanvasWidget.hxx +++ b/src/GUI/CanvasWidget.hxx @@ -47,6 +47,8 @@ class CanvasWidget: float _last_x, _last_y; + + static SGPropertyNode_ptr _time; }; #endif /* CANVASWIDGET_HXX_ */ diff --git a/src/Scripting/NasalCanvas.cxx b/src/Scripting/NasalCanvas.cxx index fffe5d5a9..b5b181e6f 100644 --- a/src/Scripting/NasalCanvas.cxx +++ b/src/Scripting/NasalCanvas.cxx @@ -181,7 +181,8 @@ naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave) .member("x", &sc::MouseEvent::getPosX) .member("y", &sc::MouseEvent::getPosY) .member("deltaX", &sc::MouseEvent::getDeltaX) - .member("deltaY", &sc::MouseEvent::getDeltaY); + .member("deltaY", &sc::MouseEvent::getDeltaY) + .member("click_count", &sc::MouseEvent::getCurrentClickCount); NasalCanvas::init("Canvas") .member("_node_ghost", &elementGetNode) .member("size_x", &sc::Canvas::getSizeX)