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

How to determie switch from document to book window

Community Expert ,
Aug 10, 2022 Aug 10, 2022

Copy link to clipboard

Copied

I have set up notifications to determine the switch between book and document for these triggers:

105 FA_Note_PostActiveDocChange
   2 FA_Note_PostOpenDoc
 77 FA_Note_PostBookComponentOpen
 17 FA_Note_PostOpenBook

Now, when switching between nothing (aka Welcome screen), book window and document window I get mixed results.

  • Nothing → Book: Notify is triggered by FA_Note_PostOpenBook
  • Nothing → Open document: Notify is triggered by FA_Note_PostOpenDoc and
    FA_Note_PostActiveDocChange
  • Document → Open Book: Notify is triggered by FA_Note_PostOpenBook
  • Book → Document: Notify triggered by FA_Note_PostActiveDocChange
  • Document → Book: Notify is not triggered. Which constant is required?

 

Any ideas, how determine whether I have left the document window and entered the book window?

 

There must be a method. The open FM Find/Change dialog switches from document to book indication when I leave the document window and click into the book window.

TOPICS
Scripting

Views

211

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 ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

Hi Klaus, on FM2019 I see FA_Note_PostActiveDocChange triggered for every combination that you list. In fact, it is sometime triggered multiple times when switching to and from "nothing."

 

How are you testing this? I did something very simple... I imagine you are doing the same.

 

Notification(Constants.FA_Note_PostActiveDocChange , true);

 

. . .

 

function Notify(note, object, sparam, iparam)
{
  switch (note)
  {
    case Constants.FA_Note_PostActiveDocChange:
      alert("Doc change");
      break;

  }

}

 

When testing, I would recommend that you restart FM between any change in notification setup. I feel that I have experienced unpredictable behavior trying to change notifications while FM is running.

 

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
Community Expert ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

Thank You, Russ, for your comments

«When testing, I would recommend that you restart FM between any change in notification setup.»

Yes this is absolutely essential - and it seems to be also important to close FM orderly so that

    case Constants.FA_Note_PreQuitSession:
      KLD_F.RemoveNotifications ();
      break;

is also executed and the notifications be removed. I have found that they survive if FM is just killed.

I have tested again:

Both a book and a document are open

Activating (cklich into) the book window does not trigger FA_Note_PostActiveDocChange. Leaving the document focus obviously is not a "change", although the document is no more active.

Activating the document of course does.

I have no idea how to get a notification when the user leaves the document and enters the book window. In a Find panel the radio buttons ("find in")  Book or Document should be automatically set from the situation (FM standard Find/Repl does).

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
Mentor ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

Hi Klaus, I just checked again to be sure. I get notification when I leave the document and enter the book window. In fact, I get a double notification. I did not investigate why there are two. Maybe I'm getting your notification by accident 🙂

 

Jokes aside, I'm not sure what else to say, what could be different from your setup. As a reminder, I'm using FM2019, but I don't suspect that has anything to do with it.

 

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
Community Expert ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

Hi Russ,

I have now the same results as You and also see what the double alert is - an indication that I am in the book window...

/* E:\_DDDprojects\_JSX-library\TestOnly\CheckNotifications1.jsx 
#target framemaker

Notification(Constants.FA_Note_PostActiveDocChange , true);

function Notify(iNote, object, sparam, iparam) {
Console ("Notify iNote = " + iNote + "   obj " + object.constructor.name);
  switch (iNote) {
    case Constants.FA_Note_PostActiveDocChange:
      alert("Doc change");
      break;
  }
}

Procedure:

  1. Both a doc and a book are open
  2. The above script is run via Script Library
  3. Console log is visible and cleared
  4. click in doc: alert + Notify iNote = 105 obj Doc
  5. click in book: alert, alert + Notify iNote = 105 obj Doc + Notify iNote = 105 obj InvalidObject
  6. click in doc: alert + Notify iNote = 105 obj Doc
    I think, with these results I can make up a test for "being in the book window".

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 ,
Aug 17, 2022 Aug 17, 2022

Copy link to clipboard

Copied

Strange things happen in the book window. It looks like the software can bounce...

 

var lastNote = undefined; // global
Notification(Constants.FA_Note_PostActiveDocChange , true);

function Notify(iNote, object, sparam, iparam) {
Console ("iNote = " + iNote + ";   obj " + object.constructor.name);
  switch (iNote) {
    case Constants.FA_Note_PostActiveDocChange:
      if (lastNote == 105 && !object.ObjectValid()) {
        Console ("Notify book recognised");
        Console ("  book: " + app.ActiveBook.Name);
      } else {
        Console ("Notify document recognised");
      }
    break;
  }
  lastNote = iNote;
  Console ("");
}

 

I click in the current document → since no change of doc, no trigger

I click in another open document → first entry in log

Then i click in the book window → 2nd to 4th entry in log

I click in the current document → 5th entry in log

 

Notify iNote = 105   obj Doc
Notify document recognised
  
Notify iNote = 105   obj InvalidObject
Notify book recognised
  book: E:\_DDDprojects\FM-JsxLib\Docu\FMjsxLib.book
  
Notify iNote = 105   obj InvalidObject
Notify book recognised
  book: E:\_DDDprojects\FM-JsxLib\Docu\FMjsxLib.book
  
Notify iNote = 105   obj InvalidObject
Notify book recognised
  book: E:\_DDDprojects\FM-JsxLib\Docu\FMjsxLib.book
  
Notify iNote = 105   obj Doc
Notify document recognised

 

Edit

in all cases sparam is «null» and iparam is 0

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 ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

Has anyone any ideas why I get a triple response (notice) for one click into the book window?

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 ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

LATEST

This test may help a little bit more to imagine what's going on in the book window:

 

#target framemaker

var lastNote = undefined, oLastObj = undefined; // global
Notification(Constants.FA_Note_PostActiveDocChange , true);

function Notify(iNote, object, sparam, iparam) {
Console ("iNote = " + iNote + "; obj " + object.constructor.name + "; sparam «" + sparam + "»; iparam " + iparam);
  switch (iNote) {
    case Constants.FA_Note_PostActiveDocChange:
      if (lastNote == 105 && !object.ObjectValid()) { // switch from doc → book window
        Console (" book " + app.ActiveBook.Name);
      } else {
        Console (" document " + object.Name);
      }
    break;
  }
  lastNote = iNote;
  oLastObj = object;
  Console ("");
}

Console log:

iNote = 105; obj Doc; sparam «null»; iparam 0 <<<< tip into document
document E:\_DDDprojects\FM-FindRepl\Developer-log.fm

 

iNote = 105; obj Doc; sparam «null»; iparam 0 <<<< tip into book A
book E:\FM-Specials\FM-15-tests\BookWindow\Book-example.book

 

iNote = 105; obj InvalidObject; sparam «null»; iparam 0
book E:\FM-Specials\FM-15-tests\BookWindow\Book-example.book

 

iNote = 105; obj InvalidObject; sparam «null»; iparam 0
book E:\FM-Specials\FM-15-tests\BookWindow\Book-example.book

 

iNote = 105; obj InvalidObject; sparam «null»; iparam 0
book E:\FM-Specials\FM-15-tests\BookWindow\Book-example.book

 

iNote = 105; obj Doc; sparam «null»; iparam 0 <<<< tip on tab of book B
book E:\_DDDprojects\FM-JsxLib\Docu\FMjsxLib.book

 

iNote = 105; obj InvalidObject; sparam «null»; iparam 0
book E:\_DDDprojects\FM-JsxLib\Docu\FMjsxLib.book

 

iNote = 105; obj InvalidObject; sparam «null»; iparam 0
book E:\_DDDprojects\FM-JsxLib\Docu\FMjsxLib.book

 

iNote = 105; obj InvalidObject; sparam «null»; iparam 0
book E:\_DDDprojects\FM-JsxLib\Docu\FMjsxLib.book

 

iNote = 105; obj Doc; sparam «null»; iparam 0 <<<< file in book A clicked
document E:\FM-Specials\FM-15-tests\BookWindow\book-file-B.fm

 

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