Skip to main content
Participating Frequently
November 9, 2009
Question

InlineGraphicElement

  • November 9, 2009
  • 1 reply
  • 742 views

Hello,

I am building a text editor based on the Text Layout Framework and have made some good progress.

An aspect of my editor is for the insertion of graphics into the Rich Text Editor and I am struggling to understand the nature and behavior of InlineGraphicElement.

In my implementation, I have a method as follows:

        public function addPhoto(displayObject:Object,width:uint,height:uint):void
        {
            var em:IEditManager = textArea.textFlow.interactionManager as IEditManager;
            em.insertInlineGraphic(displayObject,width,height);
            var graphic:InlineGraphicElement = textArea.textFlow.findLeaf(textArea.selectionActivePosition-1) as InlineGraphicElement;
        }

Which should be pretty self-explanatory.

I am not entirely sure what useful options exist as far as working with the InlineGraphicElement object.  I want to do things like put resizer handles on the object to allow it to be resized, as well as enable the item to be dragged around to be repositioned within the text it has been inserted into.

I have some ideas as to how to possible go about doing this but they seem unnecessarily complex and I just want to see if any TLF experts have any recommendations here as far as a starting point for this effort.

Thank you in advance.

This topic has been closed for replies.

1 reply

Adobe Employee
November 10, 2009

Typically you would want the resizer handles to appear in the top layer, not necessarily the layer that the inline graphic is in. So they may not be anywhere the graphic in the display list. But you will have to define some sort of tracker object that handles a click in a resizer handle and resizes the object appropriately. Then you can redraw or reposition the resizer handles in response.

As to repositioning, that will depend a lot on what you want it to do. If you want the inline to be moved around in the text, you'll have to delete it from the old position, and insert it in the new. You'll want to look through some of the hit detection code in SelectionManager to figure out which characters the inline should go between.

- robin

emansouriAuthor
Participating Frequently
November 10, 2009

So if I understand correctly, I'll need to programmatically implement the appearance of resize handlers on top of the control and then adjust the width and height properties of the InlineGraphicElement dynamically?

And as far as repositioning, I'd need to programmatically add a mirror of the item, make it draggable, and then figure out where it was dropped, remove the InlineGraphicElement from its original position, and replace it in the new position?

Sounds complicated but do-able.

Please let me know if I have misinterpreted your counsel here.

Adobe Employee
November 11, 2009

Yes, that was pretty much what I was thinking.

For the drag, it might be fastest to drag an image around, I don't know. Probably you want it on a layer above what you're dragging over, that's comething you'll have to decide. Sometimes people like a quick wireframe view, and then the real thing pops in if they pause. All these are things to consider.

- robin