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

JS: Modeless dialog

Community Beginner ,
Dec 05, 2021 Dec 05, 2021

Copy link to clipboard

Copied

Hello, I have a modeless dialog (palette) that is open in FM.

 

Is there a way to notify the dialog when the insertion point changes in the target document?

 

Looping through all tables in doc, but need to refresh the dialog if the user skips a table and selects the next one or last one.

Any help is greatly appreciated!

Views

207

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 , Dec 05, 2021 Dec 05, 2021

It is not clear to me, how the user loops through all tables.

 

But you'll get informed about changing insertion point via Notify Notification(Constants.FA_Note_PostMouseCommand,true);

 

Here is an example:

IMPORTANT: Dont forget to remove the notification when closing the dialog

var goDoc = app.ActiveDoc;
    
    if (goDoc.ObjectValid())
        {
        var oDia = new Window("palette","ShowPgfFmt");
        
        BuildDialogue();
        
        Notification(Constants.FA_Note_PostMouseCommand,
...

Votes

Translate

Translate
Enthusiast ,
Dec 05, 2021 Dec 05, 2021

Copy link to clipboard

Copied

It is not clear to me, how the user loops through all tables.

 

But you'll get informed about changing insertion point via Notify Notification(Constants.FA_Note_PostMouseCommand,true);

 

Here is an example:

IMPORTANT: Dont forget to remove the notification when closing the dialog

var goDoc = app.ActiveDoc;
    
    if (goDoc.ObjectValid())
        {
        var oDia = new Window("palette","ShowPgfFmt");
        
        BuildDialogue();
        
        Notification(Constants.FA_Note_PostMouseCommand,true);
        }
    else
        {
        alert("No active document");    
        }



function BuildDialogue()
{
    oDia.Group = oDia.add("group");
    oDia.PgfName = oDia.Group.add("statictext",undefined,"");
   
    oDia.PgfName.size = [240,40];

    oDia.onClose = RemoveNotification;  
    oDia.show();
}

function Notify(note, object)
{
    switch (note)
            {
                case Constants.FA_Note_PostMouseCommand:
                    {
                    ShowPgfName();
                    break;
                    }
            }
        }
    
function ShowPgfName()
{
    oDia.PgfName.text = ReadPgfName();
    oDia.update()
    
}

function ReadPgfName(locPgf)
{
    var tRange = goDoc.TextSelection;
    var locStartPgf = tRange.beg.obj.Name;
    alert(locStartPgf);
    return  locStartPgf;
    }

function RemoveNotification()
{
   Notification(Constants.FA_Note_PostMouseCommand,false);
}

 

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 ,
Dec 06, 2021 Dec 06, 2021

Copy link to clipboard

Copied

LATEST

Thanks Klaus!

That worked as expected, just had to change this line of code:

function ReadPgfName(locPgf)

to

function ReadPgfName()

My script scans for all tables in flow, saves the table IDs in an array and the selects the first table. On the palette I have first, previous, next, and last buttons to allow the user to move through the tables array.

This request was meant for the user to be able to scroll to a different page (or table) and select the table he/she wants to modify and click on it, without using the navigation buttons. Your script will notify the palette and update the pointer in the array to sync the table properties shown on the palette with the selectes table on the page.

Thanks again, best regards!! 🙂

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