Skip to main content
April 19, 2009
Answered

Delete inserted graphic

  • April 19, 2009
  • 1 reply
  • 1243 views

Dear Sirs,

How I can delete a inserted graphic? Also I would like to know how I can modify the position of image (with a char position), actually I think that need delete and insert in new position, but I believe that exists other method for this.

Thanks in advance.

- Marcos

This topic has been closed for replies.
Correct answer robin_briggs

How about if you group them together in a composite operation? Then the composite operation will contain both the delete and the insert, and is undone as a sinlge unit. Here's a code snippet that groups an insert with an applyFormat for similar reasons:

            editManager.beginCompositeOperation();
            SelManager.setSelection(insertPos, insertPos);
            editManager.insertText(insertText);
            SelManager.setSelection(insertPos, insertPos + insertText.length);
            var charFormat:TextLayoutFormat = new TextLayoutFormat();
            charFormat.fontSize = insertSize;
            editManager.applyFormat(charFormat,null,null);
            editManager.endCompositeOperation();

Hope this helps,

- robin

1 reply

Adobe Employee
April 20, 2009

You can delete an inline graphic by selecting it and calling IEditManager.deleteNext, or just passing to deleteNext the range that contains the inline.

Alternatively, if you are not using the edit manager and not using undo, you can get the InlineGraphicElement and call removeChild on the graphic's parent to remove the graphic. If you do it this way, then at some later point you will also have to call updateAllControllers() to see the changes (this is taken care of for you if you call the IEditManager.deleteNext).

April 21, 2009

Robin, thanks for looking this.


The major problem is the "undo" who save the deleting action, if "undo" is called, is transparent for user the two actions (deleting and inserting) rather than only one (change position). The solution that I thought was delete the last operation, calling the popUndo, but not worked because the deleted action is the former, in this case the operation of the inserting image, rather than operation of delete.

var pos: int = imagesLeaf.getAbsoluteStart();

var start: int = getEditManager().absoluteStart;

getEditManager().setSelection(pos, pos);     
getEditManager().deleteNext();
getEditManager().setSelection(start, start);
getUndoManager().popUndo();

Some idea?

Thanks in advance,
Marcos

robin_briggsCorrect answer
Adobe Employee
April 21, 2009

How about if you group them together in a composite operation? Then the composite operation will contain both the delete and the insert, and is undone as a sinlge unit. Here's a code snippet that groups an insert with an applyFormat for similar reasons:

            editManager.beginCompositeOperation();
            SelManager.setSelection(insertPos, insertPos);
            editManager.insertText(insertText);
            SelManager.setSelection(insertPos, insertPos + insertText.length);
            var charFormat:TextLayoutFormat = new TextLayoutFormat();
            charFormat.fontSize = insertSize;
            editManager.applyFormat(charFormat,null,null);
            editManager.endCompositeOperation();

Hope this helps,

- robin