How to get value from TextEditBoxWidget?

New Here ,
Mar 04, 2022 Mar 04, 2022

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

TOPICS
SDK

Views

181

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Mar 07, 2022 Mar 07, 2022
This can be done many ways. I will list what I think and you can choose and investigate these methods Save the value in a global variable, and then use it any of the files you want. Create a class(probably a singleton) that can hold all such variables that you need across files. Since it will be a singleton class you can get its instance in any file and use the value. Now some InDesign specific ways. This one is similiar to creating the class but we do that by adding an interface and implem...

Likes

Translate

Translate
Adobe Community Professional ,
Mar 04, 2022 Mar 04, 2022

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

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);
        }
    }
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

Copy link to clipboard

Copied

Hope I need to call "kOTPAuthDialogBoss" instead "kOTPDlgBoxWidgetID" am I right?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

Copy link to clipboard

Copied

Still getting null value...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 04, 2022 Mar 04, 2022

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

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...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 04, 2022 Mar 04, 2022

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

Copy link to clipboard

Copied

Sure, I will do that & share it...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

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?

Screen Shot 2022-03-05 at 12.10.01 PM.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2022 Mar 07, 2022

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".

Screen Shot 2022-03-07 at 3.34.25 PM.png

I am struggling to find a solution for this from past one month... Hope you can help on this!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 07, 2022 Mar 07, 2022

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

  • Save the value in a global variable, and then use it any of the files you want.
  • Create a class(probably a singleton) that can hold all such variables that you need across files. Since it will be a singleton class you can get its instance in any file and use the value.

Now some InDesign specific ways.

  • This one is similiar to creating the class but we do that by adding an interface and implementation to an InDesign class probably the document boss, session boss etc.
  • Use the blackbox data interface to save the value. I have not used it but it seems it allows us to save key value pair in different boss classes.
  • You could use the insertlabel method that we use in scripting from C++ and save the key value pair that way.

I hope these points give you ample amount of ideas to work upon your implementation.

-Manan

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2022 Mar 07, 2022

Copy link to clipboard

Copied

Do we have any expamle in our SDK for any of this method? (Sorry I am new to this...)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2022 Mar 07, 2022

Copy link to clipboard

Copied

Used the global variable & it works!

Thanks a lot!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 07, 2022 Mar 07, 2022

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2022 Mar 07, 2022

Copy link to clipboard

Copied

LATEST

Sure, I will look into it! Thanks for the support!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines