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

Get focus back into document

Community Expert ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Dear friends,

After opening a panel (wPalC) from the menu the focus is (of course) on the panel.
a) Before working in this panel, the user may want to open another panel wPalS (by means of a keyboard shortcut).

The focus should be back in the document for this.
b) If the user choses to work in the already open panel - no problem: Either he uses the immediate focus or as soon as he does anything there the focus is there. For example tool tips are displayed on hover, no click required.
But I have not found a method to get the focus into the document for case a).
I have this function which works fine in other circumstances:

function SetFocusToDoc (oDoc) {
var tRange = oDoc.TextSelection;
  oDoc.ScrollToText (tRange);
} //--- end SetFocusToDoc

But whether I place the call to this routine at places 1), 2) or 3) - no success. The shortcut will not be executed (no "ping" though):

function Command (cmd) {
  switch (cmd) {
//  ... 
    case 5:
      HandleCalcMarkers();              // opens panel wPalC
      wPalC.active = false;
      SetFocusToDoc (goCurrentDoc);     // 1)
      break;
    case 6:
      HandleSeriesMarkers();            // opens panel wPalS

                          
      SetFocusToDoc (goCurrentDoc);     // 2)
      break;
    case 7:
      HandleDocSettings();                          
      break;
  }
      SetFocusToDoc (goCurrentDoc);     // 3)
} //--- end Command

  1. I can get the focus in the document with the following method - not for the end-user:
  2. Run the script from ESTK with the menu setup replaced by an in-line selection list
  3. Invoke HandleCalcMarkers from this selection list. The panel is displayed and active
  4. From ESTK directly run (separate instance) SetFocusToDoc (app.ActiveDoc)
  5. In FrameMaker I see the focus in the document (blinking cursor).

How to get the focus back to the document in the script?

Any ideas welcome!

Even FM does not provide the focus in the document in all 'desired' cases, for example after Change Zoom level.

TOPICS
Scripting

Views

2.2K

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

correct answers 1 Correct answer

Enthusiast , Nov 22, 2016 Nov 22, 2016

Hi Klaus,

to go back to the document I tried to use

oDoc.IsInFront = 1;

But this didn't work.

So I tried this:

oDoc.IsInFront = 0;

oDoc.IsInFront = 1;

And it worked. So I can continue writing at once.

Votes

Translate

Translate
Enthusiast ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Hi Klaus,

to go back to the document I tried to use

oDoc.IsInFront = 1;

But this didn't work.

So I tried this:

oDoc.IsInFront = 0;

oDoc.IsInFront = 1;

And it worked. So I can continue writing at once.

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 ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Thanks, Klaus, for this simple idea!

However in my case there must be gini in the script:

My function is this:

function SetFocusToDoc (oDoc) {
  oDoc.IsInFront = 0;
  oDoc.IsInFront = 1;
//alert ("Who is in front?");
}

It is invoked after the panel had been built (locations 1) … 3) in the first post.

At the alert I see the blinking cursor in the document.

Dismissing the alert immediately puts the focus into the panel.

So the problem might be the intrinsic property of a panel: stay in foreground until explicitly left.

Hence I added "panelname.active = false" after the panel setup-call:

function Command (cmd) {
  switch (cmd) {
// ...
    case 5:
      HandleCalcMarkers(); 
      wPalC.active = false;
      break;
    case 6:
      HandleSeriesMarkers();
      wPalS.active = false;
      break;
    case 7:
      HandleDocSettings();
      wPalDS.active = false;
      break;
  }
  SetFocusToDoc (goCurrentDoc);
} //--- end Command

This works as expected!

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 ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

No, it doesn't work!

It works when there is the alert which I must dismiss - but this is not a solution.

But without the alert the focus is not in the document and I get a "ping" when trying to enter the next shortcut (ESC ...).

So I tried

      panelname.enabled = false.

But this (obviously) makes it impossible to receive any action: it can no more be dismissed. I need to kill FM.

Next idea:

      panelname.visible = false;

allows to use the short-cut for the second panel, but makes it impossible to quit the panel, although all buttons work. Only Cancel and X do not react! Very close to a solution...

Btw the Cancel button is defined within the panel as

  wPalC.g4.Cancel.onClick = function () {
    wPalC.close();
  }

Putting an

     wPalC.visible = true; 

before the close ruins the possibility for the second shortcut - not even a ping can be heared.

So I'm at the end of my lating (as we say in German).

It really seems that a panel can not be both in foreground and give focus back to the document. I propably must live with this fact.

Klaus

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 ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Hi Klaus,

try to combine it with your code above:

  1. function SetFocusToDoc (oDoc) {  
  2. var tRange = oDoc.TextSelection; 
  3.   oDoc.ScrollToText (tRange); 
  4. oDoc.IsInFront = 0; 
  5.   oDoc.IsInFront = 1; 
  6. } //--- end SetFocusToDoc 

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 ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

LATEST

This doesn't help either - actually I had tried this already but now was not certain to have used the correct call (iwth current document).

So lets close - until the very bright idea hits our brain!

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