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
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
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
Copy link to clipboard
Copied
Can you use this to bring the focus back to the document view?
doc.IsInFront = 1;
Copy link to clipboard
Copied
Thanks Rick. Tried that. Does not work.
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
Copy link to clipboard
Copied
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