Copy link to clipboard
Copied
Hi Expects,
I'm new to this community. In facebook most of them suggested to post my queries in adobe community to get better solution. Here's my query,
I coded to get the EditTextBox widget text value during button click.
Plugin gets build successfully. In Indesign when i type some text in EditTextBox and by clicking button it shows starting alert message and then InDesign gets crashed. I can't find what's the problem in my code....
if (widgetid == kGetTextButtonWidgetID)
{
CAlert::InformationAlert("1");
InterfacePtr<IPanelControlData> panelControlData(this, UseDefaultIID());
IControlView* EditTextBoxView = panelControlData->FindWidget(kSampleTextEditBoxWidgetID);
InterfacePtr<ITextControlData> EditBoxTextData(EditTextBoxView, UseDefaultIID());
PMString temp;
temp = EditBoxTextData->GetString();
PMString returnText = temp;
CAlert::InformationAlert(returnText);
}
Thanks In Advance...
Regards,
ParvathiKannan.
Copy link to clipboard
Copied
Hi Expects,
I'm new to this community. In facebook most of them suggested to post my queries in adobe community to get better solution. Here's my query,
I coded to get the EditTextBox widget text value during button click.
Plugin gets build successfully. In Indesign when i type some text in EditTextBox and by clicking button it shows starting alert message and then InDesign gets crashed. I can't find what's the problem in my code....
if (widgetid == kGetTextButtonWidgetID)
{
CAlert::InformationAlert("1");
InterfacePtr<IPanelControlData> panelControlData(this, UseDefaultIID());
IControlView* EditTextBoxView = panelControlData->FindWidget(kSampleTextEditBoxWidgetID);
InterfacePtr<ITextControlData> EditBoxTextData(EditTextBoxView, UseDefaultIID());
PMString temp;
temp = EditBoxTextData->GetString();
PMString returnText = temp;
CAlert::InformationAlert(returnText);
}
Thanks In Advance...
Regards,
ParvathiKannan.
Copy link to clipboard
Copied
Hi Parvathi,
Do you get any crash report, are you using debug build of InDesign, that should help you in debugging. The code you shared looks fine at first look but the issue could be anywhere its hard to guess. You just pasted the code of if block it may be possible there is something wrong above it and it causes a crash on method exit.
-Manan
Copy link to clipboard
Copied
Yes Manan. I'm using the debug build of InDesign.
I have refered the Adobe InDesign CS6 Plugin development document too.... Still i can't find the problem in my code.........
Here's my code.... what was the problem in it????
#include "VCPlugInHeaders.h"
// General includes:
#include "CObserver.h"
#include "ErrorUtils.h"
#include "EventUtilities.h"
#include "ILayoutUIUtils.h"
#include "ILinkFacade.h"
#include "IPasteboardUtils.h"
// Interface includes:
#include "IActiveContext.h"
#include "IControlView.h"
#include "IDropDownListController.h"
#include "IImportExportFacade.h"
#include "IPanelControlData.h"
#include "IStringData.h"
#include "IStringListControlData.h"
#include "ISpread.h"
#include "ISubject.h"
#include "IWidgetParent.h"
#include "PMString.h"
#include "URI.h"
// Project includes:
#include "CustomHttpLinkUIID.h"
#include "IScriptManager.h"
#include "IScriptRunner.h"
#include "Utils.h"
#include "IScriptUtils.h"
#include "JavaScriptID.h"
#include "IScriptUtils.h"
#include "IScriptArgs.h"
#include "CAlert.h"
#include "IExtendScriptUtils.h"
#include "ITextControlData.h"
class CustomHttpLinkUIPlaceButtonObserver : public CObserver
{
public:
CustomHttpLinkUIPlaceButtonObserver(IPMUnknown* boss);
virtual ~CustomHttpLinkUIPlaceButtonObserver() {}
virtual void AutoAttach();
virtual void AutoDetach();
virtual void Update(const ClassID& theChange, ISubject* theSubject, const PMIID &protocol, void* changedBy);
};
CREATE_PMINTERFACE(CustomHttpLinkUIPlaceButtonObserver, kCustomHttpLinkUIPlaceButtonObserverImpl)
CustomHttpLinkUIPlaceButtonObserver::CustomHttpLinkUIPlaceButtonObserver(IPMUnknown* boss)
: CObserver(boss)
{
}
void CustomHttpLinkUIPlaceButtonObserver::AutoAttach()
{
InterfacePtr<ISubject> subject(this, IID_ISUBJECT);
if (subject && !subject->IsAttached(this, IID_IBOOLEANCONTROLDATA))
subject->AttachObserver(this, IID_IBOOLEANCONTROLDATA);
}
void CustomHttpLinkUIPlaceButtonObserver::AutoDetach()
{
InterfacePtr<ISubject> subject(this, IID_ISUBJECT);
if (subject && subject->IsAttached(this, IID_IBOOLEANCONTROLDATA) && subject->IsAttached(this, IID_ITRISTATECONTROLDATA))
subject->DetachObserver(this, IID_IBOOLEANCONTROLDATA);
}
void CustomHttpLinkUIPlaceButtonObserver::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 == kGetTextButtonWidgetID)
{
CAlert::InformationAlert("1");
InterfacePtr<IPanelControlData> panelControlData(this, UseDefaultIID());
IControlView* EditTextBoxView = panelControlData->FindWidget(kSampleTextEditBoxWidgetID);
InterfacePtr<ITextControlData> EditBoxTextData(EditTextBoxView, UseDefaultIID());
PMString temp;
temp = EditBoxTextData->GetString();
PMString returnText = temp;
CAlert::InformationAlert(returnText);
}
}
}
Thanks,
-ParvathiKannan.
Copy link to clipboard
Copied
Set a breakpoint and see whether EditTextBoxView = … actually found anything.
Otherwise, the EditBoxTextData is also just a fancy NULL pointer.
Further down, better check that using " if( EditBoxTextData ) …" before you access its EditBoxTextData->GetString().
But then, as Manan suggests, in the debug build there should be an assert on the operator -> .
Maybe the problem is anywhere else.
Copy link to clipboard
Copied
So doesn't the debug build give any asserts before crashing?
-Manan
Copy link to clipboard
Copied
Hi Manan, Dirk
It shows that InDesign CC 2017 has stop working....
As per Dirk suggested i checked the EditBoxTextData again it shows the meassage InDesign CC 2017 has stop working.....
I've modified my code and found the issue....
Actually the issue occurs in
InterfacePtr<IControlView> EditTextBoxView(panel->FindWidget(kSampleTextEditBoxWidgetID), UseDefaultIID()); in this line....
InStead of kSampleTextEditBoxWidgetID i used kGetTextButtonWidgetID to check the data appears or not.....
By giving kGetTextButtonWidgetID InDesign works correctly.
In returnText it shows the kGetTextButtonWidgetID button text in alert....
How to fix my error in above mentioned line???????????
Code i've modified is
if (widgetid == kGetTextButtonWidgetID)
{
CAlert::InformationAlert("1");
InterfacePtr<IWidgetParent> myParent(this, UseDefaultIID());
InterfacePtr<IPanelControlData> panel((IPanelControlData*)myParent->QueryParentFor(IID_IPANELCONTROLDATA));
InterfacePtr<IControlView> EditTextBoxView(panel->FindWidget(kSampleTextEditBoxWidgetID), UseDefaultIID());
InterfacePtr<ITextControlData> EditBoxTextData(EditTextBoxView, UseDefaultIID());
PMString temp;
temp = EditBoxTextData->GetString();
PMString returnText = temp;
CAlert::InformationAlert(returnText);
}
Regards,
ParvathiKannan.