Highlighted

Put focus on insertion point..

Enthusiast ,
Feb 13, 2017

Copy link to clipboard

Copied

I'm trying to put the focus on the insertion point after inserting text from a palette without mouseclick.

I just want to continue writing at that point.

Things I've already tested:

- scrollToText

- oDoc.IsInFront = 1

- oDoc.TextSelection = tRange

Has anybody solved this problem?

var w = new Window ("palette","INSERT");

    w.Button = w.add("button",undefined,"Go")

    w.Button.onClick = Insert;

    w.show()

function Insert()

{

var oDoc = app.ActiveDoc

var textLoc = oDoc.TextSelection.beg; 

oDoc.AddText (textLoc, "Test"); 

}

TOPICS
Scripting

Views

4.3K

Likes

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

Put focus on insertion point..

Enthusiast ,
Feb 13, 2017

Copy link to clipboard

Copied

I'm trying to put the focus on the insertion point after inserting text from a palette without mouseclick.

I just want to continue writing at that point.

Things I've already tested:

- scrollToText

- oDoc.IsInFront = 1

- oDoc.TextSelection = tRange

Has anybody solved this problem?

var w = new Window ("palette","INSERT");

    w.Button = w.add("button",undefined,"Go")

    w.Button.onClick = Insert;

    w.show()

function Insert()

{

var oDoc = app.ActiveDoc

var textLoc = oDoc.TextSelection.beg; 

oDoc.AddText (textLoc, "Test"); 

}

TOPICS
Scripting

Views

4.3K

Likes

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
Feb 13, 2017 0
Advocate ,
Feb 13, 2017

Copy link to clipboard

Copied

Klaus,

I have a function DisplayMarker which might give a hint:

function DisplayMarker (oDoc, oCurrentMarker) {
//          Select marker to visualize the location of the current marker
//          (Text Symbols must be on to see it)
var myTextRange, oTextLoc1, oTextLoc2;

  if (oCurrentMarker.ObjectValid()) {
    oTextLoc1 = oCurrentMarker.TextLoc;
    oTextLoc2 = oCurrentMarker.TextLoc;
  } else {
    alert ("DisplayMarker:\nPgm error: oCurrentMarker not defined.", DisplayMarker.name, true);
    return false;
  }
  oTextLoc2.offset = oTextLoc2.offset+1;                  // offset2 = offset1 is given by oTextLoc
  myTextRange  = new TextRange(oTextLoc1,oTextLoc2);      // define a TextRange   
  oDoc.TextSelection = myTextRange;              // if you want to select the marker 
  oDoc.ScrollToText(myTextRange);                // requires a TextRange. NOT a location 
} //--- end DisplayMarker

It works fine.

Likes

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
Reply
Loading...
Feb 13, 2017 0
Enthusiast ,
Feb 13, 2017

Copy link to clipboard

Copied

Hi Klaus,

thanks a lot for your suggestions.

The problem is, to put the focus on the document, when working with a palette-window.

In my little script above, when you click "Go", the text is inserted at the insertion point.

What I want to do then is, just to write in the document, without clicking with the mouse to the insertion point.

Things I've already tested:

- scrollToText

- oDoc.IsInFront = 1

- oDoc.TextSelection = tRange

I've also tested Shift - F7: no success.

Likes

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
Reply
Loading...
Feb 13, 2017 0
Advocate ,
Feb 13, 2017

Copy link to clipboard

Copied

Now I understand: I also had no success in doing this.

I needed to resort to "documentation change"...

function SetFocusToDoc (oDoc) { //=== Set focus back to document after invoking panel =============

// Comment  Since the panels are per definition 'in front' they can not be influenced to give
//          focus back to the document. The user must click into the document to get it in focus
//          to be able to enter another shortcut. Of course the focus of the panel is left also
//          when reaching for the menu.
//          HENCE THIS FUNCTION IS NOT USED …
// Reference Klaus Göbel at https://forums.adobe.com/thread/2240541
var oTextRange, fcode = [];

  oTextRange = oDoc.TextSelection;
  oDoc.ScrollToText (oTextRange);
  oDoc.IsInFront = 0;                            // method Klaus Göbel -> no effect
  oDoc.IsInFront = 1;
  fcode[0] = FCodes.FOCUS_INPUT_DOC;  // <Definition \x620> new idea - no effect
    Fcodes(fcode);
} //--- end SetFocusToDoc

This seems to be a panel quirk

Likes

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
Reply
Loading...
Feb 13, 2017 1
Enthusiast ,
Feb 13, 2017

Copy link to clipboard

Copied

Hi Klaus,

thanks a lot, pointing to that solution. I'll try to work it out and give you a feedback.

  1. oDoc.IsInFront = 0;        
  2. oDoc.IsInFront = 1; 

Doing that workes only if at least 2 dokuments are open.

Ergo: It doesn't work.

Likes

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
Reply
Loading...
Feb 13, 2017 0
Engaged ,
Feb 13, 2017

Copy link to clipboard

Copied

Klaus,

I think there are two changes to get this done as ES has no window handling mechanism.

1. implement an FDK Client, which gives you access to the windows, then you'll be able to active the active document window

2. find a workaround with any function that could activate current active doc window.

Point 1, I think it's too much overhead for this. As "IsInFront" works when two documents are open but not if only one is opened, following thoughts

1. try

Assign an invalid doc to app.ActiveDoc

var doc = app.ActiveDoc

app.ActiveDoc = app.ActiveDoc.NextDocumentInSession

app.ActiveDoc = doc;

2. try

Minimize active doc and maximize it again

app.ActiveDoc.IsIconified = true;

app.ActiveDoc.IsIconified = false ;

or perhaps

app.ActiveDoc.IsOnScreen = false;

app.ActiveDoc.IsOnScreen = true;

or a combination of IsOnScreen and IsInFront

3. try

Call something like Redisplay/Reformatting

4. try

keep an hidden (empty) document. Make it visible, make it the activeDoc and than switch back to your document and hide your dummy again.

Sorry, not nice but perhaps could help

Markus

Likes

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
Reply
Loading...
Feb 13, 2017 0
Enthusiast ,
Feb 14, 2017

Copy link to clipboard

Copied

Hi Markus,

thanks a lot for your suggestions.

None of them works. The only way seems to be fcode[0] = FCodes.FOCUS_INPUT_DOC;

But there is absolutely no effect. So maybe it's a bug.

All other things only cause flickering.

Likes

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
Reply
Loading...
Feb 14, 2017 0
Engaged ,
Feb 14, 2017

Copy link to clipboard

Copied

Hi Klaus,

I woudn't call it a bug. Bug is such a hard word 🙂

I think, this all is due to a missing window messaging queue support within ExtendScript. Perhaps @AdobeTCS could bring some C-features like "BringWindowToFront" up to ExtendScript.

Window focus is on your ES Dialog, and you can't change this Focus without messaging queue support.

So I think the only way to make this work in a stable way is an FDK Client which implements a callback to FA_NoteCallClient and implements this window handling.

Sorry

Markus

Likes

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
Reply
Loading...
Feb 14, 2017 0
Mentor ,
Feb 15, 2017

Copy link to clipboard

Copied

Hi Klaus G.,

Any time I need to force a document to the front (that is, "brute force"), I call Open() on it again. Did you try that? Maybe something like:

SimpleOpen(oDoc.Name, false);

Russ

Likes

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
Reply
Loading...
Feb 15, 2017 0
Enthusiast ,
Feb 15, 2017

Copy link to clipboard

Copied

Hi Russ,

thanks for your advice.

In my case, the document already is open and on top of all other documents or it is the only open document.

But the palette-dialog overlaps it.

I have a (palette-)script, that inserts words by pressing a button. I want that the user can continue writing without having to "aim"  with the mouse without closing the dialog.

Likes

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
Reply
Loading...
Feb 15, 2017 0
Mentor ,
Feb 15, 2017

Copy link to clipboard

Copied

Hi Klaus,

I understand that. I have found that an "open" command on an open document tends to force it to the front, when other options fail. Did you try it?

Russ

Likes

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
Reply
Loading...
Feb 15, 2017 0
Enthusiast ,
Feb 15, 2017

Copy link to clipboard

Copied

Hi Russ,

I've just tried. It only flickers.

Klaus

Likes

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
Reply
Loading...
Feb 15, 2017 0
Mentor ,
Feb 15, 2017

Copy link to clipboard

Copied

Confound it! I thought I had the answer. Thanks for trying.

Likes

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
Reply
Loading...
Feb 15, 2017 0
Engaged ,
Feb 16, 2017

Copy link to clipboard

Copied

just another idea:

try to set active property of your palette to false and after that try one of suggestions above.

Would start with SimpleOpen, as Russ suggested.

Markus

Likes

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
Reply
Loading...
Feb 16, 2017 0
K.Daube LATEST
Advocate ,
Mar 01, 2017

Copy link to clipboard

Copied

Following Markus' last advice I can place the text:

#target framemaker
var w = new Window ("palette","INSERT"); 
        w.Button = w.add("button",undefined,"Go") 
        w.Button.onClick = Insert; 
        w.show() 

function Insert()  { 
    var oDoc = app.ActiveDoc 
    var textLoc = oDoc.TextSelection.beg;
    w.active = false;   // Markus' suggestion
    oDoc.AddText (textLoc, "Test");   
}

So, does this work in a real-world script also?

Likes

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
Reply
Loading...
Mar 01, 2017 0