|
03-28-2018, 09:56 AM
|
#1
|
Human being with feelings
Join Date: Mar 2018
Location: Portugal
Posts: 7
|
Different Double Cilck Behaviours for each kobs
I have been trying to figure this out without success. I have 3 knobs and I want them to react differently when the user double-clicks them: 1 knob must reset to 0, and the other 2 will do nothing when double-clicked on.
I know there's a IGraphics::OnMouseDblClick function that controls the behavior of double clicking... and my initial idea was to make two copies of that function and modify them to my liking, but the problem is that I can't understand *how* OnMouseDblClick is called... so I can't just go to the code and say:
"Okay, whenever a knob is double-clicked on, use OnMouseDblClickCustom instead of the regular OnMouseDblClick."
And if I don't know how to do that, I certainly don't know how to go a step further and call different double-click functions for different knobs.
Any help would be greatly appreciated!!
|
|
|
03-29-2018, 04:23 AM
|
#2
|
Human being with feelings
Join Date: May 2012
Location: PA, USA
Posts: 356
|
I think you would want to do something like this:
-Create your own custom knob class that inherits whatever control you are currently using.
-Add a private/protected variable. Something like bool bResetOnClick
-Add a function to change the variable. Something like void SetOnClick(bool x){bResetOnClick = x;}
-In the plugin constructor where you initialize the knobs, call the new function to set the bResetOnClick
-Override OnMouseDblClick to look at the bResetOnClick. If it is true, do the same code that is in the base class.
I don't think you want to start messing with the base class, although you could if you want.
|
|
|
03-29-2018, 10:11 AM
|
#3
|
Human being with feelings
Join Date: Mar 2018
Location: Portugal
Posts: 7
|
Since it's the class IGraphics that has the function OnMouseDblClick, the idea would be creating an IGraphics2 class which would inherit from IGraphics and then override OnMouseDblClick in a way that would serve my purposes, correct?
I have been trying to do that unsuccessfully. Because when I do something like:
IGraphics2* pGraphics;
(...)
pGraphics = MakeGraphics(this, kWidth, kHeight);
It tells me that it can't convert from IGraphics* to IGraphics2*, which I think it means it's not recognizing the funcion MakeGraphics as inherited.
Any thoughts?
|
|
|
03-29-2018, 12:21 PM
|
#4
|
Human being with feelings
Join Date: May 2012
Location: PA, USA
Posts: 356
|
You don't want to create a new IGraphics class, you want to create a new IControl. You are probably using the IKnobControl class. Just inhereit that, and override the OnMouseDblClick part.
|
|
|
03-29-2018, 02:23 PM
|
#5
|
Human being with feelings
Join Date: Mar 2018
Location: Portugal
Posts: 7
|
Unfortunately, that's where the problem lies.
There are multiple OnMouseDblClick functions across different classes... but only the one in IGraphics affects the behaviour of the knobs.
If I //comment the content of the OnMouseDblClick found in IPlugMultiTargets_control or IControl, the knobs continue to behave normaly. If I do the same to the OnMouseDblClick in IGraphics, the knobs stop working when I double click them.
I don't understand why, but that's why I'm trying to find a solution using IGraphics.
|
|
|
03-30-2018, 01:03 PM
|
#6
|
Human being with feelings
Join Date: May 2012
Location: PA, USA
Posts: 356
|
Typically you would want to make a control class that handles the double click behavior. You could also have different knob controls. One control that doesn't do anything, and one that does reset on double click.
There is nothing wrong with creating several/many different types of controls. I have knobs that show text underneath, knobs that don't, knobs that have a separate stitched bitmap shadow attached, etc.
The IGraphics OnMouseDbleClick really just finds the control that was clicked by the mouse, and passes the information to the individual control. If a particular control class doesn't override the OnMouseDblClick function, the default is to use the base class function in IControl (which will reset the control).
|
|
|
03-30-2018, 01:08 PM
|
#7
|
Human being with feelings
Join Date: Mar 2018
Location: Portugal
Posts: 7
|
Quote:
Originally Posted by random_id
The IGraphics OnMouseDbleClick really just finds the control that was clicked by the mouse, and passes the information to the individual control. If a particular control class doesn't override the OnMouseDblClick function, the default is to use the base class function in IControl (which will reset the control).
|
Funny, I just realized that 30 minutes ago, ahah. I haven't implemented all the code yet but I'm fairly sure I can follow your suggested approach without any problems. Thanks a lot, you've been very helpful!
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 02:24 PM.
|