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

ScriptUI Palette Focus After Clicking Button

Community Beginner ,
Mar 01, 2019 Mar 01, 2019

Copy link to clipboard

Copied

Hello, first time poster here!

I am working on developing an InDesign palette and I have run into an issue surrounding clicking buttons. The palette that I am working on is something that I want to stay open so that the user can interact with it while they work on their InDesign document. I want key focus to be on the document after clicking buttons in the palette and I am a bit stuck.

Here is my use case: I click a button in the palette and it selects multiple frames on the page. I then want to be able to use arrow keys to nudge the frames around (for example). I can’t use the arrow keys to move the objects until I click back into the document because the palette is holding key focus.

How do I tell my script to return focus to the InDesign document while keeping the palette open?

Any feedback is appreciated!

Thanks,

Jeremy

TOPICS
Scripting

Views

2.2K

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

Guide , Mar 01, 2019 Mar 01, 2019

Hi Jeremy,

(…)

How do I tell my script to return focus to the InDesign document while keeping the palette open?

Invoke app.activate() whenever you need to give the focus back to InDesign.

Something like this:

myButton.onClick = function onClickHandler()

{

app.select( app.activeDocument.spreads[0].pageItems.everyItem().getElements() );

app.activate();

};

Best,

Marc

Votes

Translate

Translate
Guide ,
Mar 01, 2019 Mar 01, 2019

Copy link to clipboard

Copied

Hi Jeremy,

(…)

How do I tell my script to return focus to the InDesign document while keeping the palette open?

Invoke app.activate() whenever you need to give the focus back to InDesign.

Something like this:

myButton.onClick = function onClickHandler()

{

app.select( app.activeDocument.spreads[0].pageItems.everyItem().getElements() );

app.activate();

};

Best,

Marc

Votes

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
Community Beginner ,
Mar 01, 2019 Mar 01, 2019

Copy link to clipboard

Copied

I tried that but it's not working as expected. Here is a dummy script that I set up to test that approach:

#targetengine 'session'

var myDoc = app.activeDocument;

var myTextFrame = myDoc.textFrames[0];

var myDialog = new Window ("palette","Layers",undefined, {resizeable:true});

myDialog.preferredSize = [300,300];

var selectButton = myDialog.add("button", undefined, "Select The Things");

selectButton.onClick = function (){

    app.selection = myTextFrame;

    app.activate();

    };

myDialog.show();

app.activate();

Votes

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
Guide ,
Mar 01, 2019 Mar 01, 2019

Copy link to clipboard

Copied

Well your dummy script works for me 😕

The app recovers the focus and I can move the text frame using arrow keys…

Tested on Win10 with ID 14.0.

Maybe a Mac issue (?)

@+

Marc

Votes

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
Community Beginner ,
Mar 01, 2019 Mar 01, 2019

Copy link to clipboard

Copied

Oh man, I bet it is a Mac issue... I hadn't considered that!

What a pain in the shoes...

Votes

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 ,
Sep 20, 2019 Sep 20, 2019

Copy link to clipboard

Copied

Hello,

 

Marc's answer sometimes worked for me on Win7 InDesign 2019 and sometimes didn't. Then I found out that in order to work 100% of the time I had to "reset" the selection first with 

     app.selection = null;

before I select whatever I wanted to select.

     app.selection = myInsertionPoint;
     app.activate();

 

Chris

 

 

Votes

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
Participant ,
Dec 27, 2020 Dec 27, 2020

Copy link to clipboard

Copied

Sorry for digging up such an old thread, but the answer Marc provided doesn't work for me either (nor Chris' tip with app.selection = null). With an open panel, app.activate() doesn't do anything on the Mac. Hope it's not just a bug.

 

Thanks!

Votes

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
Engaged ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

LATEST

I can confirm this (non-)behaviour for Mac even all the years after the original post. Please vote on uservoice:

https://indesign.uservoice.com/forums/601180-adobe-indesign-bugs/suggestions/46096285-scirptui-in-ev...

Votes

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