Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

InDesign Tool: How I could enable/disable a tool

Contributor ,
Jun 03, 2010 Jun 03, 2010

Hi All,

I am looking into a way usnig which I can enable/disable a tool.

e.g. On openning a plugin Idialog  want to disable "Text type tool" and enable it when plugin dialog is closed.

Do we have control on these eanbling/disabling of InDesign tool.

Regards,

Alam

TOPICS
SDK
17.6K
Translate
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
Explorer ,
Jun 03, 2010 Jun 03, 2010

alam:

   The way I did it was to build an observer, wait until conditions were met, then I would run this code:

   do
   {
      InterfacePtr <IPanelControlData> PControlData(this, UseDefaultIID());
      ASSERT(PControlData);

      if(PControlData == nil)
         break;

      IControlView* CView = PControlData -> FindWidget(kWPCPSelPgEdtBxWidgetID);  //  get control view for widget
      ASSERT(CView);

      if(CView == nil)
         break;

      if(widget == kWPCPPSelPg__RWWidgetID)  //  some kind of test to determine what you want to do...this step may not be necessary.
      {
         CView -> Enable();

         WPCPDialogObserver::bTextEnabled = kTrue;  //  This was a flag I needed to set for other parts of the code.
      }
      else
      {
         CView -> Disable();

         WPCPDialogObserver::bTextEnabled = kFalse;

      }
   }
   while(kFalse);

If the tool is in another dialog, then create a static pointer to itself in the class, create a static member function to retrieve that pointer, be sure to set the pointer to this when initializing the plugin, and when leaving the plugin set it to NULL.  Then call the member function to get the pointer, and use the pointer to call the function that will enable/disable the tool you want enabled/disabled.  It would look something like this:

MyDialog MyDialog::ptr = NULL;

class MyDialog::CDialogController  (Or observer, whatever is more appropriate)

{

  ...

  static MyDialog *ptr;

  static GetMyDialogPtr() {return ptr;}

}

MyDialog::MyDialog()

{

   ptr = this;

}

MyDialog::~MyDialog()

{

   ptr = NULL;

}

MyDialog::enableTool()

{

  //  Whatever

}

/*  and in other code  */

OtherClass::DoSomething()

{

   MyDialog *DialogPtr = MyDialog::GetMyDialogPtr();

   if(!DialogPtr)

   {

      CAlert::ErrorAlert("Sorry, that plugin is not active");

      /*  Take appropriate remedial activity  */

   }

   DialogPtr -> enableTool();

}

There may be some problems with threading issues with this scheme; I haven't had to cope with that yet, but I suspect there are some moderately simple steps that could be taken to make this thread safe.

I hope this gives you an idea of how you might do what you want to do.

R,

John

Translate
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
Contributor ,
Jun 03, 2010 Jun 03, 2010

Thanks for your reply,

I think you could not understand what I want to achieve.

I need to disable InDesign "Text Type tool" on openning my plugin dialog.

Regards,

Alam

Translate
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
Mentor ,
Jun 04, 2010 Jun 04, 2010

There are multiple kinds of dialogs. You probably want a modal dialog.

If you just want typing by default to hit your window rather than others, see IKeyboard acquireFocus (or similar name). That should be implicitly called when the dialog opens, unless your dialog has no text edit fields, e.g. just custom drawn widgets.

If you want something more esoteric such as set the tool to be dimmed in the toolbar so that the user can not click it but still continue with e.g. the path tool, that's more work.

If you just want to choose a different tool from your dialog, that's again something different.

Dirk

Translate
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
Contributor ,
Jun 04, 2010 Jun 04, 2010

Thanks for your reply.

Please let me elaborate on my requirement.

Here I am refering the tool in indesign toolbar and I want to prevent the usage of that tool, So that  while my plugin is running. user can not able to use that particular tool.

Regards,

Alam

Translate
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
Explorer ,
Jun 04, 2010 Jun 04, 2010

Alam, you are right. I did not understand your need and, alas, I cannot tell you how to turn off a tool

already in the InDesign toolbar though I suspect it can be done if you know the boss.

Translate
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
Contributor ,
Jun 07, 2010 Jun 07, 2010

Thanks for your reply,

I have solved my problem as follows.

1. Get the ITool interfcae from IToolBoxUtils::QueryActiveTool;

2. Get the IControlView from Itool and disable the tool.

Regards,

Alam

Translate
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
Explorer ,
Jun 07, 2010 Jun 07, 2010

Alam:

This is actually really good information to have. I may try it in a snippet just for practice!

Take care,

R,

John

Translate
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
Mentor ,
Jun 07, 2010 Jun 07, 2010

I'm glad you could resolve that. I would have attempted to find any more official place where the tool manager picks up the criteria to actually do the enabling, but my spare time has been very limited recently.

If you have to strictly prevent text edits, also consider a TextPreProcess service.

For your test cases:

- select some text and open the story editor window (Cmd+Y), before you show your dialog and do your magic. If you click into that story editor window you might still be able to do text edits ...

- try a double click into any text frame, rather than switching tools via tool bar.

- If you have any (but text) selection, typing "T" should also choose the text tool.

- Would an Undo step that undoes a text change confuse your code?

- Find & Change, spell checker and so forth may also alter text.

- Drag and drop of text from an outside editor, or from file system.

- Drag/move, remove, duplicate etc. any XML elements in structure view.

Dirk

Translate
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
Contributor ,
Jun 07, 2010 Jun 07, 2010
LATEST

Thanks for your reply,

Actually I need to disable the "Page Tool" in indesign CS5.

Regards,

Alam

Translate
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