Skip to main content
Participant
July 29, 2014
Question

Undo support around extendscript command

  • July 29, 2014
  • 1 reply
  • 1511 views

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");

This topic has been closed for replies.

1 reply

Legend
July 30, 2014

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

Participating Frequently
May 26, 2015

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();
frameexpert
Community Expert
Community Expert
May 26, 2015

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

www.frameexpert.com