COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 08-02-2018, 11:36 AM   #1
Gubbles
Human being with feelings
 
Gubbles's Avatar
 
Join Date: Jul 2018
Posts: 4
Default How to Release IContactControl

Hey, first time making a plugin here! XD

Using the WDL_OL library and getting a bit stuck with the IContactControl. Essentially I want an effect to activate when I click and hold down a button, and have it stop when I release. However the effect "sticks" after I release the button. The description for this in IControl.h reads "A switch that reverts to 0.0 when released", but what exactly is being reverted to 0.0 here? I'm aware there's an OnMouseUp() function, but I'm not sure how to implement it.
Gubbles is offline   Reply With Quote
Old 08-03-2018, 02:12 PM   #2
Gubbles
Human being with feelings
 
Gubbles's Avatar
 
Join Date: Jul 2018
Posts: 4
Default

Figured it out! Just have to assign a parameter to the button, and check to see if the parameter associated with the button is pressed in OnParamChange(). I was dumb and didn't realize you can stack if statements within switch statements, whoops. XD

The implementation, if anyone else is wondering:

Code:
// Set up IContactControl with parameter
GetParam(kPad)->InitBool("Pad", 0);
pGraphics->AttachControl(new IContactControl(this, xpos, ypos, kPad, &bitmap));
Then setting up what to do in OnParamChange();

Code:
// Get whether pad is held down or not
void Example::OnParamChange(int paramIdx) {
	IMutexLock lock(this);

	switch (paramIdx) {

		case kPad:
			if (GetParam(kPad)->Value()) {
				// Pad is held down
				// Do thing
			}
			else {
				// Pad is released
				// Do other thing
			}
		// Other parameters...
	}
}
Gubbles 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 04:12 AM.


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