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
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
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
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();
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
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...
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
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!
Copy link to clipboard
Copied
I can confirm this (non-)behaviour for Mac even all the years after the original post. Please vote on uservoice: