COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 01-26-2017, 08:18 AM   #1
$h@d0 link
Human being with feelings
 
Join Date: Jan 2017
Posts: 9
Default OnMouseDrag not being called?

So I need to be able to tell when the mouse gets dragged up and down in my plugin. So I look in The example solution "IPlugMouseTest" and it has nice simple working code that detects when the mouse gets dragged in different directions, great! but when I implement almost identical code in my plugin the OnMouseDrag function never gets called! wtf? Here is my code

Code:
 
class DragIncrementer : public IControl
{
public:
	DragIncrementer(IPlugBase *pPlug, IRECT pR, int paramA, int paramB,float bpmChange)
		: IControl(pPlug, pR)
	{
		AddAuxParam(paramA);
		AddAuxParam(paramB);
		AddAuxParam(bpmChange);
	}

	int lastY;

	bool Draw(IGraphics* pGraphics)
	{
		return true;
	}

	void OnMouseDown(int x, int y, IMouseMod* pMod)
	{
		lastY = y;
	}

	void OnMouseUp(int x, int y, IMouseMod* pMod)
	{
		lastY = 0;
	}

	void OnMouseDrag(int x, int y, IMouseMod* pMod)
	{
		int bpmChange = y - lastY;
		lastY = y;
		GetAuxParam(2)->mValue = bpmChange;
		SetDirty();
	}


	void SetDirty(bool pushParamToPlug = true)
	{
		mDirty = true;

		if (pushParamToPlug && mPlug)
		{
			SetAllAuxParamsFromGUI();
		}
	}
private:

};
Then I create this control just like in the example
Code:
pGraphics->AttachControl(new DragIncrementer(this, IRECT(0, 0, kWidth, kHeight), kPitchA, kPitchB, bpmInc));
where pGraphics is my IGraphics pointer

The OnMouseDown and OnMouseUp functions get called no problem. When I set breakpoints inside OnMouseDrag() the debugger tells me "The breakpoint will not currently be hit. No executable code of the debugger's target type is associated with this line. Possible causes include: conditional compilation, compiler optimizations, or the target architecture of this line is not supported by the current debugger code type"

Really baffled by this one, hope someone has an idea of what it could be. I really like the way IPlug allows for a lot of customizing your own controls, however I seem to have nothing but problems with trying to get it to work properly.
$h@d0 link is offline   Reply With Quote
Old 01-26-2017, 08:48 AM   #2
gstuff
Human being with feelings
 
Join Date: Feb 2014
Posts: 63
Default

Your method has the wrong signature.
You should be overriding IControl's:
Code:
virtual void OnMouseDrag(int x, int y, int dX, int dY, IMouseMod* pMod) {}

Last edited by gstuff; 01-26-2017 at 10:23 AM.
gstuff is offline   Reply With Quote
Old 01-26-2017, 04:50 PM   #3
$h@d0 link
Human being with feelings
 
Join Date: Jan 2017
Posts: 9
Default Thank you!

Can't believe I missed that, oh well I am a noob so I forgive myself. Thank you.
$h@d0 link 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 01:59 PM.


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