COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 03-28-2018, 09:56 AM   #1
MLN
Human being with feelings
 
MLN's Avatar
 
Join Date: Mar 2018
Location: Portugal
Posts: 7
Default 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!!
MLN is offline   Reply With Quote
Old 03-29-2018, 04:23 AM   #2
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

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.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 03-29-2018, 10:11 AM   #3
MLN
Human being with feelings
 
MLN's Avatar
 
Join Date: Mar 2018
Location: Portugal
Posts: 7
Default

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?
MLN is offline   Reply With Quote
Old 03-29-2018, 12:21 PM   #4
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

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.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 03-29-2018, 02:23 PM   #5
MLN
Human being with feelings
 
MLN's Avatar
 
Join Date: Mar 2018
Location: Portugal
Posts: 7
Default

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.
MLN is offline   Reply With Quote
Old 03-30-2018, 01:03 PM   #6
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

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).
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 03-30-2018, 01:08 PM   #7
MLN
Human being with feelings
 
MLN's Avatar
 
Join Date: Mar 2018
Location: Portugal
Posts: 7
Default

Quote:
Originally Posted by random_id View Post
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!
MLN is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.