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

Raising an event from a script

Advocate ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

Is there anyone who has had to trigger an event from a script? I am building an alternative elements catalog but the PostInsertElement, PostWrapElement and PostChangeElement events are not fired and there might be other clients that use those.

 

Thanks in advance.

 

Jang

TOPICS
Scripting , Structured

Views

3.0K

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
Mentor ,
May 01, 2020 May 01, 2020

Copy link to clipboard

Copied

Hi Jang, can you clarify your question? Are you saying that you can't get any notification to work? I have not had any trouble with them. For example, when the script first runs, I enable like this:

 

Notification(Constants.FA_Note_PostInsertElement , true);

 

Then use this function to respond:

 

function Notify(note, object, sparam, iparam)
{
     switch (note) 
    {
        case Constants.FA_Note_PostInsertElement:
        
            alert("Hi there");
                
            break;
     }
}

 

But there is something odd about it all, let me see if I can remember. It has something to do with how notifications only work if enabled during FM startup. Or at least this much... I think that once you enable a notification in any specific script file, that file gets copied to the FM userdata startup folder, which for me is (FM2019):

 

C:\Users\rward\AppData\Roaming\Adobe\FrameMaker\15\startup

 

Then, FM always reads the script from that location on startup and I cannot run the script again to change anything. So, I have a sandbox area where I work on scripts, but then another batch script that copies the files to the startup folder. Then I restart FM to test. If the script does not execute from that area on startup, notifications do not work.

 

That is not a very clear answer, because it has been a while and I don't remember the exact behavior. I hope it provides you some clues. Short answer... for me, unlike other script activities, notifications only seem to work right if configured on startup. They can't be changed during an active session. If I remember. Could be wrong.

 

Russ

 

 

 

 

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
Advocate ,
May 01, 2020 May 01, 2020

Copy link to clipboard

Copied

Hello Russ,

Thanks for the reply, but all of that is working fine. I need the other side of the story - not catching an event in my script (which I am doing for a lot of events already) but raising one, so that FrameMaker gets notified of a new event. My script adds elements to a structured document and I would want to have possible clients react on the fact that a new element was injected. One of the issues I am having is that the focus is not moved back to the active document: after injecting an element, the users needs to click somewhere in the document or the Structure View before they can start typing content. That is annoying. If you have a method that moves the focus back to the document view that would be a good alternative.

Thanks again

Jang

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 Expert ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

Can you use this to bring the focus back to the document view?

doc.IsInFront = 1;

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
Advocate ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

Thanks Rick. Tried that. Does not work.

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
Enthusiast ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

Hi Jang,

that's a problem I'm faced since years and got no solution yet.

Maybe some of the hints and tips may help you:

https://community.adobe.com/t5/framemaker/put-focus-on-insertion-point/m-p/8872868?page=1

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
Advocate ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

LATEST

Hello Klaus,

I have already tried that code. Nothing works so far. And it should really be possible to raise an event from the script (or from FDK code, for that matter). I will keep bothering the dev team about it until they give in 🙂

Ciao

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