Copy link to clipboard
Copied
I am always getting null value fro a widget that I created,
Widget values,
TextEditBoxWidget
(
kOTPDlgBoxWidgetID, // widget ID
kSysEditBoxPMRsrcId, // PMRsrc ID
kBindNone, // frame binding
Frame(95,10,320,30) // left, top, right, bottom
kTrue, // visible
kTrue, // enabled
0, // nudgeWidgetId (0 if no nudge
1.0, // small nudge amount
5.0, // large nudge amount
6, // max num chars
kFalse, // read only flag
kFalse, // should notify on each key stroke
kTrue, // range checking enabled
kTrue, // blank entry allowed
30.0, // upper limit
0.0, // lower limit
"", // control label
),
Observer:
#include "VCPlugInHeaders.h"
// Interface includes:
#include "IControlView.h"
#include "IPanelControlData.h"
#include "ISubject.h"
// General includes:
#include "CDialogObserver.h"
#include "VCPlugInHeaders.h"
#include "CAlert.h"
#include "PreferenceUtils.h"
#include "IAppPersistance.h"
#include "IAppPersistCmdData.h"
#include "IDropDownListController.h"
#include "IStringListControlData.h"
#include "ITextControlData.h"
// Project includes:
#include "IDToHttpID.h"
#include "IDToHtppUtilities.h"
class OTPDialogObserver : public CDialogObserver
{
public:
OTPDialogObserver(IPMUnknown* boss) : CDialogObserver(boss) {
}
virtual ~OTPDialogObserver() {}
virtual void AutoAttach();
virtual void AutoDetach();
virtual void Update(const ClassID& theChange, ISubject* theSubject, const PMIID &protocol, void* changedBy);
virtual void AttachToWidget(const WidgetID& widgetId, const PMIID& iidOfDataToObserve);
virtual void DetachFromWidget(const WidgetID &widgetId,const PMIID &iidOfDataObserver);
};
CREATE_PMINTERFACE(OTPDialogObserver, kOTPDialogObserverImpl)
void OTPDialogObserver::AutoAttach()
{
CDialogObserver::AutoAttach();
do
{
AttachToWidget(kOTPDlgBoxWidgetID, IID_IBOOLEANCONTROLDATA);
AttachToWidget(kOKButtonWidgetID, IID_IBOOLEANCONTROLDATA);
AttachToWidget(kCancelButton_WidgetID, IID_IBOOLEANCONTROLDATA);
} while (false);
}
void OTPDialogObserver::AttachToWidget(const WidgetID& widgetId, const PMIID& iidOfDataToObserve)
{
InterfacePtr<IPanelControlData> panelData(this, IID_IPANELCONTROLDATA);
IControlView* view = panelData->FindWidget(widgetId);
if (view) {
InterfacePtr<ISubject> subject(view, IID_ISUBJECT);
if (subject)
subject->AttachObserver(this, iidOfDataToObserve);
}
}
void OTPDialogObserver::AutoDetach()
{
CDialogObserver::AutoDetach();
do
{
DetachFromWidget(kOTPDlgBoxWidgetID, IID_IBOOLEANCONTROLDATA);
DetachFromWidget(kOKButtonWidgetID, IID_IBOOLEANCONTROLDATA);
DetachFromWidget(kCancelButton_WidgetID, IID_IBOOLEANCONTROLDATA);
} while (false);
}
void OTPDialogObserver::DetachFromWidget(const WidgetID &widgetId,const PMIID &iidOfDataObserver)
{
InterfacePtr<IPanelControlData> iiPanelData(this,IID_IPANELCONTROLDATA);
IControlView* iiView = iiPanelData->FindWidget(widgetId);
if(iiView)
{
InterfacePtr<ISubject> iiSubject(iiView,IID_ISUBJECT);
if (iiSubject)
{
iiSubject->DetachObserver(this,iidOfDataObserver);
}
}
}
/* Update*/
void OTPDialogObserver::Update
(
const ClassID& theChange,
ISubject* theSubject,
const PMIID &protocol,
void* changedBy
)
{
CDialogObserver::Update(theChange, theSubject, protocol, changedBy);
do
{
InterfacePtr<IControlView> controlView(theSubject, UseDefaultIID());
if (controlView == nil)
{
ASSERT_FAIL("OTPDialogObserver::Update() controlView invalid");
break;
}
// Get the button ID from the view.
WidgetID theSelectedWidget = controlView->GetWidgetID();
if (theSelectedWidget == kOKButtonWidgetID && theChange == kTrueStateMessage)
{
}
} while (false);
}
Thanks,
Robin
This can be done many ways. I will list what I think and you can choose and investigate these methods
Now some InDesign specific ways.
Copy link to clipboard
Copied
The kTextEditBoxWidgetBoss has an interface ITextControlData which has a method GetString
So query this interface inside your update method, when the widgetID is of the kTextEditBoxWidgetBoss and the call the method.
-Manan
Copy link to clipboard
Copied
Tried this too....
void OktaQtnDialogObserver::Update
(
const ClassID& theChange,
ISubject* theSubject,
const PMIID &protocol,
void* changedBy
)
{
if (theChange == kTrueStateMessage)
{
// Check for the widget id
InterfacePtr<IControlView> view(this, UseDefaultIID());
WidgetID widgetid = view->GetWidgetID();
if (widgetid ==kOTPDlgBoxWidgetID)
{
InterfacePtr<IPanelControlData> panelControlData(this, UseDefaultIID());
IControlView* EditTextBoxView = panelControlData->FindWidget(kOTPDlgBoxWidgetID);
InterfacePtr<ITextControlData> EditBoxTextData(EditTextBoxView, UseDefaultIID());
PMString temp;
temp = EditBoxTextData->GetString();
PMString returnText = temp;
CAlert::InformationAlert(returnText);
}
}
}
Copy link to clipboard
Copied
Hope I need to call "kOTPAuthDialogBoss" instead "kOTPDlgBoxWidgetID" am I right?
Copy link to clipboard
Copied
Still getting null value...
Copy link to clipboard
Copied
What do you mean by null value? Does the code reach CAlert at all, or some interface above it is null? The widget id is fine in the findwidget method. Look at WriteFishPrice sample plugin, that should have code interacting with texteditboxes.
-Manan
Copy link to clipboard
Copied
A new popup will open based on soap response (if success), on that popup user will have to enter the password.
So I need to read the value that user entered in that popup window. But it's returns empty...
Copy link to clipboard
Copied
That is fine. If that is the case a better place to put this code would have been inside the dialog controller, rather than the observer. Anyhow if you are not able to get it working, add the relevant bits of code to a sample plugin like Writefishprice and send that across, I can have a look at it. Just show the dialog on any event like the click of the about plugin menu etc and then we can have a look at your dialog.
-Manan
Copy link to clipboard
Copied
Sure, I will do that & share it...
Copy link to clipboard
Copied
I build the "Writefishprice", but it's menu shows disabled when I place this build inside plugin folder.
Am I miss anything?
Copy link to clipboard
Copied
Get it to work by following your answer from https://community.adobe.com/t5/indesign-discussions/writefishprice-plugin-dialog-not-opening-when-cl...
Copy link to clipboard
Copied
Hi Manan,
I can able to get the value from texteditbox if I use the get function within the controller. But I just realized my issue, I am trying to get vaule from one controller to another, not sure hot to to move the value from one controller to another.
On below snapshot, I am getting the value from "OktaSecQuestionController.cpp" & I need to pass this value to "AuthDialogController.cpp".
I am struggling to find a solution for this from past one month... Hope you can help on this!
Copy link to clipboard
Copied
This can be done many ways. I will list what I think and you can choose and investigate these methods
Now some InDesign specific ways.
I hope these points give you ample amount of ideas to work upon your implementation.
-Manan
Copy link to clipboard
Copied
Do we have any expamle in our SDK for any of this method? (Sorry I am new to this...)
Copy link to clipboard
Copied
Used the global variable & it works!
Thanks a lot!
Copy link to clipboard
Copied
Good that you got a version working. But I would highly encourage you to look at the interface/implementation add route I mentioned. This is very intrinsic to InDesign plugin development and you need to be comfortable with this. To start, read the programming guide shipped in the docs folder of the sdk, it nicely explains what it is, why it is and how to go about creating it.
-Manan
Copy link to clipboard
Copied
Sure, I will look into it! Thanks for the support!