November 19, 2015
I'd like to track Mouse enter and mouse exit events on my controls (for mouse over helper text, display knob values, etc.).
VSTGUI has an IMouseObserver with onMouseEntered and onMouseExited, however, I am unable to get successful calls to either of those functions after implementing them. I have tried on both the main class derived from CPlugIn in my own project, as well as implementing them in VSTGUIController from the CustomViewsFive project.
I have verified that my Frames and Views have mouseEnabled.
I would appreciate any insights on how to proceed.
January 29, 2017
IMouseObserver is designed for, and implemented on the CFrame object (see both the VSTGUI docs and frame.h). To get mouse notifications at the frame level, subclass CFrame and then override/implement the functions in your derived class. You can do this in the VSTGUIController in CustomViewsFive. You need to subclass your own CFrame object and then set the member variable to your object in the open( ) method:
// --- construct the frame
frame = new CMyFrame(frameSize, this);
Then you catch mouse activity in your derived CMyFrame class.
However, CView also handles mouse notifications, indirectly through IMouseObserver via the frame. If you want to catch mouse activity at the control (CView) level, just subclass whatever controls you need notification for, then override/implement the mouse functions. See cview.h for the base class function prototypes.
You can easily test this by using the CustomViews project:
1) modify the CKnobWCP object by overriding the mouse functions in KnobWCP.h
2) implement the overridden functions in the KnobWCP.cpp file
3) un-comment the CKnobWCP instantiation in showCUI( ), and comment out the line above it:
// --- custom reverse version
CKnobWCP* pKnob = new CKnobWCP(rect, etc......
Then, you can set breakpoints in the mouse message handlers to catch and monitor the events for that knob.
So, the answer is to subclass your frame and/or view objects to catch the mouse events. This will depend on the level of mouse activity that you need to catch (frame vs. view).
November 19, 2015
Upon further investigating I realized the frame needs to register the mouse observer. ( frame->registerMouseObserver(IMouseObserver *observer) )
This allows any class to extend IMouseObserver and be used as the observer, no need to subclass CFrame.
So in the CustomViewsFive project I just had VSTGUIController extend IMouseObserver, implemented the onMouseEnter() and onMouseExited() methods, then set the frame's mouse observer to VSTGUIController
// inside VSTGUIController.cpp
The onMouseEntered and onMouseExited provide the CView on what your mouse has moved over so I'll extend CView so that I can check when my custom control gets moused over and then access the extra stuff like tool tip text for that control.
Most Users Ever Online: 36
Currently Browsing this Page:
Guest Posters: 1
Newest Members:Matt, dspstudent, strings4v, TheSmile, semihyavuzz, alfredLue, danioc, midnightskate3, Alia5, Shamal Sundar
Moderators: W Pirkle: 209
Administrators: Tom: 67, JD Young: 80, Will Pirkle: 0, W Pirkle: 209