COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 02-20-2019, 03:43 PM   #1
Space Raiders
Human being with feelings
 
Join Date: Aug 2017
Posts: 69
Default How to Make Momentary Switch?

What's up everybody - it's your pal Space Raiders here with another question.

How would I go about creating a momentary switch? i.e. hold it down and the value is high - release it and the value is low. I tried creating a class inheriting from IVSwitchControl and overriding onMouseDown but it didn't seem to trigger.

Anyway, bye and thanks for the help.
Space Raiders is offline   Reply With Quote
Old 02-21-2019, 10:27 AM   #2
k.d.iv
Human being with feelings
 
Join Date: Mar 2018
Posts: 28
Default

I'm preaty sure that in IPlug1 repo, there is an Example project IPlugControls.
I think the thing you searching for is the IContactControl class used in the project.
k.d.iv is offline   Reply With Quote
Old 02-21-2019, 02:36 PM   #3
Space Raiders
Human being with feelings
 
Join Date: Aug 2017
Posts: 69
Default

Quote:
Originally Posted by k.d.iv View Post
IPlug1
Thanks for the response. I appreciate it. I have been using iPlug2 because I thought the old one was out-dated. Do you think it would be best to use iPlug?
Space Raiders is offline   Reply With Quote
Old 02-22-2019, 04:06 AM   #4
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

I'm still on IPlug 1 with WDL-Youlean for the Cairo features, but would be good to move to IPlug 2 at some point. However, you can use IPlug 2, but look at the older version's examples to see how the momentary button was implemented, and then build your own custom momentary button control.
Bobflip is offline   Reply With Quote
Old 02-22-2019, 10:29 AM   #5
k.d.iv
Human being with feelings
 
Join Date: Mar 2018
Posts: 28
Default

OK. I checked IControls header file in IPlug2 repo. Looks like this type of control is removed.

This is the class from Youlean WDL - IControl.h:
Code:
// A switch that reverts to 0.0 when released.
class IContactControl : public ISwitchControl
{
public:
  IContactControl(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBitmap)
    : ISwitchControl(pPlug, x, y, paramIdx, pBitmap) {}
  ~IContactControl() {}

  void OnMouseUp(int x, int y, IMouseMod* pMod);
};
and Implementation of it - IControl.cpp:
Code:
void IContactControl::OnMouseUp(int x, int y, IMouseMod* pMod)
{
  mValue = 0.0;
  SetDirty();
}
Hope you can fit it in your custom control
k.d.iv is offline   Reply With Quote
Old 02-23-2019, 10:09 AM   #6
Space Raiders
Human being with feelings
 
Join Date: Aug 2017
Posts: 69
Default

Thanks for the help everyone.

Code:
class IVSwitchControlMomentary : public IVSwitchControl {
public:
  IVSwitchControlMomentary(
    IRECT bounds,
    int paramIdx = kNoParameter,
    IActionFunction actionFunc = FlashCircleClickActionFunc,
    const char* str = "",
    const IVColorSpec& colorSpec = DEFAULT_SPEC,
    int numStates = 2
  ) :
  IVSwitchControl(bounds, paramIdx, actionFunc, str, colorSpec, numStates){};
  void OnMouseUp(float x, float y, const IMouseMod& mod) override{
    mValue = 0.0;
    SetDirty(true);
  }
};
Space Raiders is offline   Reply With Quote
Old 02-24-2019, 04:51 AM   #7
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

https://github.com/iPlug2/iPlug2/blo...Controls.h#L35
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin 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 07:01 AM.


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