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

Undo support around extendscript command

Community Beginner ,
Jul 29, 2014 Jul 29, 2014

Copy link to clipboard

Copied

This probably should be obvious, but how can "undo" be supported for a custom command(in Framemaker 10?  I found app.beginUndoGroup() for another product but frame gives an unknown method call for this.

The following will delete with Ctrl-Q, but "undo" remains greyed out.  Thanks in advance.

function demoDelete() {

    var doc = app.ActiveDoc;

    if (!doc) {

        alert("No active document");

        return;

    }

    var range = doc.TextSelection;

    if (range.beg.offset == range.end.offset) {

        alert("Need to select some text");

        return;

    }

    doc.DeleteText(range);

}

function Command(cmd) {

    app.beginUndoGroup("demoCsr Command");

    switch (cmd) {

    case 1111: {

        demoDelete();

    }

    app.endUndoGroup();

}

var cmd = DefineCommand(1111, "demoCsrXrefInsert", "demoCsrXrefInsert", "^q");

TOPICS
Scripting

Views

1.4K

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
Mentor ,
Jul 30, 2014 Jul 30, 2014

Copy link to clipboard

Copied

JHowe,

I don't know about this for sure, but I've always believed that there is no undo for an FDK or ES action, unless you track it and undo it yourself. There used to be hardly any undo for FM at all, so I'd be real surprised if it was extended to the automation interfaces. Of course, I'd be interested to find out otherwise.

Russ

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
Contributor ,
May 26, 2015 May 26, 2015

Copy link to clipboard

Copied

Very belated, but for the benefit of those like myself who are searching the archives, this worked for me:

// enable FDK undo recording; this is false by default, maybe for performance
app.UndoFDKRecording = true;

// get document for editing; subsequent error checking omitted
var doc = app.ActiveDoc;

// start of FDK calls for grouping together as a single undoable action;
// the given description appears as Edit > Undo My Description
doc.UndoStartCheckPoint("My Description");

// do stuff to the document that you might want to undo

// end of FDK calls for grouping together as a single undoable action
doc.UndoEndCheckPoint();

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 ,
May 26, 2015 May 26, 2015

Copy link to clipboard

Copied

There was another discussion on undos here: Re: Re: ES for FM10: Adding text at insertion point

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
Contributor ,
May 26, 2015 May 26, 2015

Copy link to clipboard

Copied

LATEST

Thanks! That discussion mentions undo a lot. I wish I'd found it earlier.

I guess I've just learnt to use the Search Communities dialog, which would have found it:

https://forums.adobe.com/search.jspa?q=undo&place=%2Fplaces%2F1414099

rather than the tempting looking Type to filter by text dialog, which doesn't find it:

https://forums.adobe.com/community/framemaker/extendscript/content?filterID=contentstatus[published]...

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