Hi, how are you doing?
I’m trying to use the MouseWatcher object but I don’t know why most of the functions throws false or 0.
Letmme show you what I’m doing
// In class as a property
MouseWatcher *m_oMouseWatcher;
// In the init method of my class
MouseWatcher::init_type();
m_oMouseWatcher = DCAST (MouseWatcher, m_oWindow->get_mouse().node());
// In different methods I'm calling from the main loop
m_nMouseX = m_oMouseWatcher->get_mouse_x();
m_nMouseY = m_oMouseWatcher->get_mouse_y();
m_bHasMouse = m_oMouseWatcher->has_mouse();
The first two methods (get_mouse_x() and get_mouse_y()) returns always 0 and the last one (has_mouse) gives me always false.
If I use m_oWindow->get_graphics_window()->get_pointer(0).get_x(); to get the x value instead using the mousewatcher it’s ok, it gaves me the x axis of the mouse but it’s very weird… does anyone knows what I’m doing wrong?
It sounds like the MouseWatcher node isn’t connected in the data graph properly. The data graph is a special graph of nodes, similar to the scene graph, but one in which parent-child relationships indicate the flow of data from the user. In general, parent nodes generate data and child nodes receive it.
In order to receive the mouse activity, the MouseWatcher node must be a child of the MouseAndKeyboard node.
Try putting:
notify-level-dgraph spam
in your Config.prc to show all of the datagraph operations. You should be able to run pview, for instance, with this enabled, and you’ll see the mouse data (among lots of other stuff) propagating through the data graph. Then try the same thing in your own application and see if you can tell what’s going on.