COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 01-10-2019, 05:57 AM   #1
StAN
Human being with feelings
 
Join Date: Oct 2014
Posts: 13
Default iPlug2 Issue: Hide control

Hello!

Please help. I need at a value of 0 show control, if not 0, hide control.
__________________________________________________ _______________________
YES:
void MyTest::OnParamChange(int paramIdx)
{
switch (paramIdx)
{
case kGain:
mGain = GetParam(paramIdx)->Value() / 100.;
if (mGain<=0) {
GetUI()->GetControl(hidehide)->Hide(false);
}
break;

default:
break;
}
}
__________________________________________________ _______________________
NO:
void MyTest::OnParamChange(int paramIdx)
{
switch (paramIdx)
{
case kGain:
mGain = GetParam(paramIdx)->Value() / 100.;
if (mGain<=0) {
GetUI()->GetControl(hidehide)->Hide(false);
} else{
GetUI()->GetControl(hidehide)->Hide(true);
}
break;

default:
break;
}
}
__________________________________________________ ____________________________
error:
void *Get() const { return m_size?m_buf:NULL; } // returns NULL if size is 0
Thread 1: EXC_BAD_ACCESS (code=1, address=0x34)
StAN is offline   Reply With Quote
Old 01-11-2019, 07:34 AM   #2
Kotozaurus
Human being with feelings
 
Join Date: Jan 2019
Posts: 2
Default

You can use boolean, for example

plugin constructor{

isHidden=true;
control->Hide(true);
}

void MyTest::OnParamChange(int paramIdx)
{
switch (paramIdx)
{
case kGain:
mGain = GetParam(paramIdx)->Value() / 100.;
if (mGain<=0)
{
control->Hide(false);
isHidden=false;
} else if(!isHidden)
{
control->Hide(true);
isHidden=true;
}
break;
Kotozaurus is offline   Reply With Quote
Old 01-11-2019, 09:03 AM   #3
Kotozaurus
Human being with feelings
 
Join Date: Jan 2019
Posts: 2
Default

As it seems to me, I found a more correct solution. As noted in another thread, the problem is that mLayoutFunc is called later than other functions,
therefore IControl objects are not initialized. I tried to initialize them before mLayoutFunc, and in mLayoutFunc only use AttachControl. Everything works fine.
Kotozaurus is offline   Reply With Quote
Old 01-11-2019, 01:24 PM   #4
StAN
Human being with feelings
 
Join Date: Oct 2014
Posts: 13
Default

Quote:
Originally Posted by Kotozaurus View Post
As it seems to me, I found a more correct solution. As noted in another thread, the problem is that mLayoutFunc is called later than other functions,
therefore IControl objects are not initialized. I tried to initialize them before mLayoutFunc, and in mLayoutFunc only use AttachControl. Everything works fine.
Thank you so much!
StAN 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 12:59 AM.


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