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
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.
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.
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.
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!
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
Copy link to clipboard
Copied
Hi Klaus,
try to combine it with your code above:
Copy link to clipboard
Copied
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!