OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

How do I continuously read the mouse position as the mouse is moving, without a click event in osg


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Krzysief
Newbie


Joined: 06 Feb 2019
Posts: 6

PostPosted: Wed Feb 06, 2019 2:02 pm    Post subject:
How do I continuously read the mouse position as the mouse is moving, without a click event in osg
Reply with quote

Hi,

I want to read the mouse location at any time, but unfortunately when i try to read it for example when event type is FRAME, it always gives me the last clicked mouse coordinates.

Thank you!

Cheers,
Kris
Back to top
View user's profile Send private message
kornerr
Appreciator


Joined: 01 Oct 2013
Posts: 309

PostPosted: Fri Feb 08, 2019 11:13 am    Post subject:
How do I continuously read the mouse position as the mouse is moving, without a click event in osg
Reply with quote

Hi.

Not sure why you "read" it during FRAME events. I personally create a
class that:
* inherits osgGA::GUIEventHandler
* overrides its bool handle(const osgGA::GUIEventAdapter
&eventAdapter, osgGA::GUIActionAdapter &actionAdapter, osg::Object
*object, osg::NodeVisitor *visitor) method

bool handle(...) method is where you get notified of mouse events once
you subscribe that class of yours to osg::Viewer events by using
osg::Viewer's addEventHandler(...) method

For example, here's my Mouse class:
https://github.com/OGStudio/openscenegraph-cross-platform-examples/blob/master/05.NodeSelection/desktop/src/input.h#L84

On Fri, 8 Feb 2019 at 14:03, Kris Bartowski <> wrote:
Quote:

Hi,

I want to read the mouse location at any time, but unfortunately when i try to read it for example when event type is FRAME, it always gives me the last clicked mouse coordinates.

Thank you!

Cheers,
Kris

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75598#75598








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Krzysief
Newbie


Joined: 06 Feb 2019
Posts: 6

PostPosted: Fri Feb 08, 2019 11:30 am    Post subject:
Reply with quote

Hi,

I read it during frame events, becouse i tought that maybe every frame the current mouse position is updated.

Thank you!

Cheers,
Kris
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12348

PostPosted: Sat Feb 09, 2019 11:11 am    Post subject:
How do I continuously read the mouse position as the mouse is moving, without a click event in osg
Reply with quote

Hi Kris,

On Fri, 8 Feb 2019 at 12:46, Kris Bartowski <> wrote:
Quote:
I read it during frame events, becouse i tought that maybe every frame the current mouse position is updated.

The OSG source code is a resource that you can use to answer all the
questions you might have, so I would recommend just getting to know
the code base and the underpinnings on classes like
osgGA::GUIEventAdapter.

The OSG doesn't poll the mouse x,y position each new frame, it only
tracks mouse position though the osgGA::GUIEventAdapter objects
generated by mouse move, mouse drag and mouse press/release events.
The mouse position is cached and passed on to new non mouse events for
your convenience.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Krzysief
Newbie


Joined: 06 Feb 2019
Posts: 6

PostPosted: Sat Feb 09, 2019 1:37 pm    Post subject:
Reply with quote

Hi,

Of course first which i tried was checking the mouse position on move events, but they weren't firing at all.

Thank you!

Cheers,
Kris
Back to top
View user's profile Send private message
Krzysief
Newbie


Joined: 06 Feb 2019
Posts: 6

PostPosted: Tue Feb 12, 2019 11:52 am    Post subject:
Re: How do I continuously read the mouse position as the mouse is moving, without a click event in osg
Reply with quote

Quote:

Hi.

Not sure why you "read" it during FRAME events. I personally create a
class that:
* inherits osgGA::GUIEventHandler
* overrides its bool handle(const osgGA::GUIEventAdapter
&eventAdapter, osgGA::GUIActionAdapter &actionAdapter, osg::Object
*object, osg::NodeVisitor *visitor) method

bool handle(...) method is where you get notified of mouse events once
you subscribe that class of yours to osg::Viewer events by using
osg::Viewer's addEventHandler(...) method

For example, here's my Mouse class:
https://github.com/OGStudio/openscenegraph-cross-platform-examples/blob/master/05.NodeSelection/desktop/src/input.h#L84

On Fri, 8 Feb 2019 at 14:03, Kris Bartowski <> wrote:


I tried your version but still - it stores mouse position only after clicking
Back to top
View user's profile Send private message
gwaldron (Glenn Waldron)
Appreciator


Joined: 25 Aug 2011
Posts: 246

PostPosted: Tue Feb 12, 2019 1:56 pm    Post subject:
How do I continuously read the mouse position as the mouse is moving, without a click event in osg
Reply with quote

Kris,You want to install an osgGA::GUIEventHandler, override the handle method, and listen for the MOVE or DRAG events. DRAG fires when moving the mouse with a button down.
Glenn Waldron / osgEarth







On Fri, Feb 8, 2019 at 6:03 AM Kris Bartowski < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi,

I want to read the mouse location at any time, but unfortunately when i try to read it for example when event type is FRAME, it always gives me the last clicked mouse coordinates.

Thank you!

Cheers,
Kris

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75598#75598





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Krzysief
Newbie


Joined: 06 Feb 2019
Posts: 6

PostPosted: Wed Feb 13, 2019 7:32 am    Post subject:
Re: How do I continuously read the mouse position as the mouse is moving, without a click event in osg
Reply with quote

gwaldron wrote:
Kris,You want to install an osgGA::GUIEventHandler, override the handle method, and listen for the MOVE or DRAG events. DRAG fires when moving the mouse with a button down.
Glenn Waldron / osgEarth







On Fri, Feb 8, 2019 at 6:03 AM Kris Bartowski < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi,

I want to read the mouse location at any time, but unfortunately when i try to read it for example when event type is FRAME, it always gives me the last clicked mouse coordinates.

Thank you!

Cheers,
Kris

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75598#75598





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum


That's what i do, but for some reason ea->getEventType() is never equal to osgGA::GUIEventAdapter::MOVE, i am notified only when the DRAG and PUSH events fire.

I use OpenSceneGraph Library 3.2.3

~Kris
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Wed Feb 13, 2019 10:43 am    Post subject:
How do I continuously read the mouse position as the mouse is moving, without a click event in osg
Reply with quote

Hi Kris,


are you on windows? If so, you can force the Windows Manager to pass all events to the osgView. Here is some snippet:


osgViewer::CompositeViewer::Windows wins; viewer->getWindows(wins);
while (!viewer->done()) {
#if defined(_WIN32) MSG msg; if (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) { ::GetMessage(&msg, NULL, 0, 0);
if (wins.size()) { osgViewer::GraphicsHandleWin32 *hdl = dynamic_cast<osgViewer::GraphicsHandleWin32*>(wins.at(0)); if(hdl) { WNDPROC fWndProc = (WNDPROC)::GetWindowLongPtr(hdl->getHWND(), GWLP_WNDPROC); if (fWndProc && hdl->getHWND()) { ::CallWindowProc(fWndProc,hdl->getHWND(),msg.message, msg.wParam, msg.lParam); } } } } #endif


On Wed, Feb 13, 2019 at 8:31 AM Kris Bartowski < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

gwaldron wrote:
Quote:
Kris,You want to install an osgGA::GUIEventHandler, override the handle method, and listen for the MOVE or DRAG events. DRAG fires when moving the mouse with a button down.
Glenn Waldron / osgEarth







On Fri, Feb 8, 2019 at 6:03 AM Kris Bartowski < ()> wrote:


Quote:
Hi,

I want to read the mouse location at any time, but unfortunately when i try to read it for example when event type is FRAME, it always gives me the last clicked mouse coordinates.

Thank you!

Cheers,
Kris

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75598#75598 (http://forum.openscenegraph.org/viewtopic.php?p=75598#75598)





_______________________________________________
osg-users mailing list
  ()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)



  ------------------
Post generated by Mail2Forum


That's what i do, but for some reason ea->getEventType() is never equal to osgGA::GUIEventAdapter::MOVE, i am notified only when the DRAG and PUSH events fire.

I use OpenSceneGraph Library 3.2.3

~Kris

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75624#75624





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
Krzysief
Newbie


Joined: 06 Feb 2019
Posts: 6

PostPosted: Wed Feb 27, 2019 6:46 am    Post subject:
Re: How do I continuously read the mouse position as the mouse is moving, without a click event in osg
Reply with quote

Trajce Nikolov NICK wrote:
Hi Kris,


are you on windows? If so, you can force the Windows Manager to pass all events to the osgView. Here is some snippet:


osgViewer::CompositeViewer::Windows wins; viewer->getWindows(wins);
while (!viewer->done()) {
#if defined(_WIN32) MSG msg; if (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) { ::GetMessage(&msg, NULL, 0, 0);
if (wins.size()) { osgViewer::GraphicsHandleWin32 *hdl = dynamic_cast<osgViewer::GraphicsHandleWin32*>(wins.at(0)); if(hdl) { WNDPROC fWndProc = (WNDPROC)::GetWindowLongPtr(hdl->getHWND(), GWLP_WNDPROC); if (fWndProc && hdl->getHWND()) { ::CallWindowProc(fWndProc,hdl->getHWND(),msg.message, msg.wParam, msg.lParam); } } } } #endif


On Wed, Feb 13, 2019 at 8:31 AM Kris Bartowski < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

gwaldron wrote:
Quote:
Kris,You want to install an osgGA::GUIEventHandler, override the handle method, and listen for the MOVE or DRAG events. DRAG fires when moving the mouse with a button down.
Glenn Waldron / osgEarth







On Fri, Feb 8, 2019 at 6:03 AM Kris Bartowski < ()> wrote:


Quote:
Hi,

I want to read the mouse location at any time, but unfortunately when i try to read it for example when event type is FRAME, it always gives me the last clicked mouse coordinates.

Thank you!

Cheers,
Kris

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75598#75598 (http://forum.openscenegraph.org/viewtopic.php?p=75598#75598)





_______________________________________________
osg-users mailing list
  ()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)



  ------------------
Post generated by Mail2Forum


That's what i do, but for some reason ea->getEventType() is never equal to osgGA::GUIEventAdapter::MOVE, i am notified only when the DRAG and PUSH events fire.

I use OpenSceneGraph Library 3.2.3

~Kris

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75624#75624





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


--
trajce nikolov nick

------------------
Post generated by Mail2Forum


Hi

I'm on ubuntu 18.04 and still dealing with this problem
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Question about idle event handling in... ollydbg General 0 Thu Oct 03, 2019 9:41 am View latest post
No new posts How to handlle the window closing eve... blackball General 1 Wed May 01, 2019 9:10 am View latest post
No new posts osgViewer GraphicsWindowX11 Event Han... ericstancliff General 4 Wed Apr 24, 2019 9:43 pm View latest post
No new posts How to hide mouse cursor? Ligvest General 1 Thu Mar 28, 2019 1:40 pm View latest post
No new posts Mouse Events are impossible to work with Steal General 0 Fri Mar 15, 2019 4:02 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP