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

Page item selection question...

Contributor ,
May 15, 2023 May 15, 2023

Hi There,

Please can someone point me in the right direction.

I've written a script that lists objects in a document in a listbox.

Currently the user can select an item in the list, press an OK button, and then be taken to the item using app.documents[0].allPageItems[k].select() when the dialog has closed. That all works fine. What I'm trying to do is create a new button, which I've done, but assign an onClick action to select the page item whilst the dialog is still open.

Is that possible using app.documents[0].allPageItems[k].select() or do I need something different?

So far that line is throwing an error. I know the ID of the page object is correct though.

Please can somone help.

Thanks.

TOPICS
Scripting , SDK
1.1K
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

correct answers 1 Correct answer

Contributor , May 17, 2023 May 17, 2023

Hi Brian,

Thanks for the post.

Yes, I had thought the .select(). I have been writing something that let's the user interrogate object settings via a ScriptUI palette. If they're not happy with something they can double-click the item and they're taken to it.

Thanks for the info re multiple spreads, I'll have to make a note of that.

Translate
LEGEND ,
May 15, 2023 May 15, 2023

What error? How do you read "k" for the 2nd button? 

 

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 ,
May 16, 2023 May 16, 2023

Thanks for the response Robert.

I'm using var docItems = myPage.allPageItems; to get all the objects and looping through them.

I did wonder if it was due to the dialog still being open. If I execute that line after the dialog has closed it works ok.

Thanks again.

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
People's Champ ,
May 15, 2023 May 15, 2023

I would presume that you are either using the dialogs class or ScriptUI for dialog but in modal state (Window). In both case, you can't interact with app as long as dialog is open. 

To get this to work, you would need ScriptIUI and a type "palette" for you window (also remind about the #targetengine "session" instruction).

Think at the moment UXP Scripts only provide modal dialogs as well.

HTH
Loic

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 ,
May 16, 2023 May 16, 2023

Hi Loic,

Thanks for the help.

I did wonder if it might be something to do with the dialog being open as the code works if I close the dialog first. I am using ScriptUI and the type 'dialog' however, I'll now have a look at the 'palette' type.

Thanks once again for the help.

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
People's Champ ,
May 16, 2023 May 16, 2023

And for that one, you really need to add the target engine instruction so that the palette stays open. Otherwise, it will simply vanishes as soon as it was displayed.

#targetengine "session"

var w = new Window ("palette"…

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
Community Expert ,
May 15, 2023 May 15, 2023

Hi @deckarduk,

This is most probably due to the modal dialog thing that @Loic.Aigon mentioned. In case you are still not able to fix it, share the relevant portion of your code so that we could help better.

Also, what is the error message that you get, that should give us a hint on what is wrong.

-Manan

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 ,
May 16, 2023 May 16, 2023

Hi Manan,

Thanks for the help. As mentioned above, I did wonder if it had something to do with the dialog still being open.

As for the error message, I'm not sure about that. Do you have a preferred method for reporting them?

Thanks again.

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
Community Expert ,
May 16, 2023 May 16, 2023

Hi @deckarduk,

You mentioned that the line is throwing an error, so it must be giving some error message as well. Please share that here.

-Manan

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
Community Expert ,
May 16, 2023 May 16, 2023

Have you thought about why you are wanting to use .select() in the first place? More often than not, select just gets in the way. You are better off just caching a reference to the selected objects and operating on them within the script after the modal dialog has closed, without the use of select, unless there's a particular reason why you need to select the object(s). Note that you also cannot select objects on multiple spreads. 

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 ,
May 17, 2023 May 17, 2023
LATEST

Hi Brian,

Thanks for the post.

Yes, I had thought the .select(). I have been writing something that let's the user interrogate object settings via a ScriptUI palette. If they're not happy with something they can double-click the item and they're taken to it.

Thanks for the info re multiple spreads, I'll have to make a note of that.

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