Skip to main content
April 8, 2011
Question

EditManager.applyLink not removing links if there is no selection

  • April 8, 2011
  • 1 reply
  • 579 views

If the cursor is 'inside' a link, editManager.applyLink(null, null, true) does not remove the link.  If, instead, you have a small selection that includes a subset of the link, it works as expected.  Is this the intended behavior?

My current workaround is attached, but it has the sideeffect of causing the cursor's position to be lost.  Is there a way around that problem?

Edit: I was incorrect about losing the cursor position.  The process of removing the link was shifting the focus, and a simple setFocus call fixed that problem.  Is this workaround otherwise reasonable?

var edit:EditManager = textFlow.interactionManager as EditManager;

if(edit.isRangeSelection()) {      edit.applyLink(null, null, true); } else {      edit.beginCompositeOperation();      var position:int = edit.absoluteStart;      edit.selectRange(position, position+1);      edit.applyLink(null, null, true);      edit.selectRange(position, position);      edit.endCompositeOperation(); }

Message was edited by: mattrichard

This topic has been closed for replies.

1 reply

Participating Frequently
April 9, 2011

I think the bug you mentioned has been fixed in Vellum 2.0. Please use the latest Vellum 2.0 library

April 14, 2011

Gang Cai wrote:

I think the bug you mentioned has been fixed in Vellum 2.0. Please use the latest Vellum 2.0 library

Assuming that "Vellum" is the old code name for the TLF framework, I am using revision 456 from the sourceforge svn, and still seeing this behavior.

(My TextLayoutVersion.CURRENT_VERSION is 33554432)

Participating Frequently
April 15, 2011

Hi:

Vellum is the internal code name. It should be equal to TLF...

Back to your issues, I think I am using exactly the same version as yours. I am not quite sure the entire context of your codes and what exatly you means about shifting the cursor issue. But I tried the following code to simulate yours. May be we can have a discussion based on this version of codes:

public class SourceforgeVerification extends Sprite

{

private var _beginPos:int = 35;

private var _endPos:int = 42;

public function SourceforgeVerification()

{

trace("TextLayout version is:" + TextLayoutVersion.CURRENT_VERSION);

var textFlow:TextFlow = new TextFlow();

var p:ParagraphElement = new ParagraphElement();

textFlow.addChild(p);

var span:SpanElement = new SpanElement();

span.text = "There are many such lime-kilns in that tract of country,";

span.fontSize = 12;

p.addChild(span);

var editMan:EditManager = new EditManager();

textFlow.interactionManager = editMan;

editMan.selectRange(30,50);

editMan.applyLink ("www.sohu.com");

textFlow.flowComposer.addController(new ContainerController(this, 400, 200));

textFlow.flowComposer.updateAllControllers();

editMan.selectRange(_beginPos,_endPos);

if(editMan.isRangeSelection()) {

editMan.applyLink(null, null, true);

} else {

editMan.beginCompositeOperation();

var position:int = editMan.absoluteStart;

editMan.selectRange(position, position+1);

editMan.applyLink(null, null, true);

editMan.selectRange(position, position);

editMan.endCompositeOperation();

}

var fl:FlowElement = editMan.textFlow.findLeaf(35) as FlowElement;

var linkEl:LinkElement = fl.getParentByType(LinkElement) as LinkElement;

//the linkEl still exists, so output is false

trace("If link element removed? "+ !linkEl);

}

}

The results on my platform should be:

Begin Pos: 25 End Pos: 30

If link element removed? false

Begin Pos: 25 End Pos: 31

If link element removed? true

Begin Pos: 35 End Pos: 42

If link element removed? true

Begin Pos: 30 End Pos: 50

If link element removed? true

Begin Pos: 35 End Pos: 55

If link element removed? true

Begin Pos: 51 End Pos: 55

If link element removed? false

This behavior is what we expected when we implemented TLF 2.0. I am not sure what's your expected behavior?

In TLF 1.0, the results of "Begin Pos: 35 End Pos: 55" and "Begin Pos: 25 End Pos: 31" will be false. In TLF 2.0, we fixed it. The codes in your version should reflect that change. So I assume it should work fine.

Anyway, please feel free to tell us what is your expected results. Thanks