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

Bringing the active table under focus when script is interrupted by a dialog box

Community Beginner ,
Jun 30, 2015 Jun 30, 2015

Copy link to clipboard

Copied

I have customized a script that browse tables into a Fm file and prompt the user if he wants the current active table to be reformated or not

I haven't find a clean way to have the table that is currently selected in the variable "tbl" to be visible on the screen when the scripts sends a dialog.

The workaround that I have found consists in starting some formating on the table before sending the prompt, in that case the currently processed table is visible when the prompt arises.

But I would like to have the table visible and avoid doing any processing on the table before the user has had a chance to answer the prompt.

I assume there must be a method to bring the focus of the active window on an element that is selected in a variable?

function ApplyTableFormat(doc)
{
    if (doc.ObjectValid())
    {
        var tbl = doc.SelectedTbl
        var tbltitle;
        var tblTextItem;
        while (tbl.ObjectValid())
        {
            tbltitle = "";
            tblTextItem = tbl.FirstPgf.GetText(Constants.FTI_String);
              for (var i = 0 ; i < tblTextItem.length; i++)
              {
                   tbltitle += tblTextItem.sdata ;
              }

            /* How to make my "tbl" visible in the active doc window ? */ 
            if(Alert("Formating: " + tbl.FirstPgf.PgfNumber + tbltitle +" ?\nClick cancel to abort.",Constants.FF_ALERT_CANCEL_DEFAULT))
                 return;
            /* insert table formating code here */

            tbl = tbl.NextTblInDoc;
        }
    }
    else
    {
      Alert ("No active doc" ,Constants.FF_ALERT_CONTINUE_WARN)
      return
    }
}

TOPICS
Scripting

Views

242

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

Community Expert , Jun 30, 2015 Jun 30, 2015

There is a document function that will scroll the window to a particular text location:

doc.ScrollToText (textRange);

You might be able to do something like this:

doc.ScrollToText (new TextRange (tbl.TextLoc, tbl.TextLoc));

-Rick

Votes

Translate

Translate
Community Expert ,
Jun 30, 2015 Jun 30, 2015

Copy link to clipboard

Copied

There is a document function that will scroll the window to a particular text location:

doc.ScrollToText (textRange);

You might be able to do something like this:

doc.ScrollToText (new TextRange (tbl.TextLoc, tbl.TextLoc));

-Rick

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 Beginner ,
Jul 01, 2015 Jul 01, 2015

Copy link to clipboard

Copied

LATEST

Thank you Rick!

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