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

Problem with SelectionState, plase help

New Here ,
Apr 01, 2012 Apr 01, 2012

Copy link to clipboard

Copied

Hi

I've tried create list and convert it to plain text at runtime.

With creating text evrething is ok    

   

     var tf:TextLayoutFormat = editor.getFormatOfRange(null, editor.selectionAnchorPosition, editor.selectionActivePosition);    

     var selState : SelectionState = new SelectionState(editor.textFlow, editor.selectionAnchorPosition, editor.selectionActivePosition);

     var listFormar : TextLayoutFormat = tf;

     listFormar.listStyleType = ListStyleType.DISC;

     listFormar.listStylePosition = ListStylePosition.OUTSIDE;

     var operation : CreateListOperation = new CreateListOperation(selState, null, listFormar);

     operation.doOperation();

With this evtething is ok - list was created.

But when I've tried to convert selected text from list to plain text I have problem. I've selected list but SelectedState return all textFlow from editor (RichEditableText), and I can't receive root list element. Please help to select list in textFlow.

var selState : SelectionState = new SelectionState(editor.textFlow, editor.selectionAnchorPosition, editor.selectionActivePosition);

TOPICS
Text layout framework

Views

3.3K

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
New Here ,
Apr 04, 2012 Apr 04, 2012

Copy link to clipboard

Copied

Tell me please, how to determine the DOM elements in TextFlow in RichEditableText by MouseClick?

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
Apr 04, 2012 Apr 04, 2012

Copy link to clipboard

Copied

I pasted a code scrap of how to enumerate the listElements. Hope it will be helpful

//this test case will check up to three level nested lists

                              //create three lists

                              SelManager.createList();

                              SelManager.createList();

                              SelManager.createList();

                              var tf:TextFlow = SelManager.textFlow;

                              var listsFound:int = 0;

                              var elem:FlowElement = tf.getChildAt(0);

                              while (elem)

                              {

                                        if (elem as ListElement)

                                        {

                                                  var listElement:ListElement = elem as ListElement;

                                                  var allListElement:Array = [];

                                                  var a:int = 0;

                                                  allListElement = listElement;

                                                  var elem2:FlowElement = listElement.getChildAt(0);

                                                  var e:FlowGroupElement = FlowGroupElement (elem2);

                                                  var i:int=0;

                                                  while (i < e.mxmlChildren.length)

                                                  {

                                                            if (e.mxmlChildren as ListElement)

                                                            {

                                                                      var listElement1:ListElement = e.mxmlChildren as ListElement;

                                                                      var elem3:FlowElement = listElement1.getChildAt(0);

                                                                      var e1:FlowGroupElement = FlowGroupElement (elem3);

                                                                      var j:int=0;

                                                                      while (j < e1.mxmlChildren.length)

                                                                      {

                                                                                if (e1.mxmlChildren as ListElement)

                                                                                {

                                                                                          listsFound++;

                                                                                          a++;

                                                                                          allListElement = e1.mxmlChildren as ListElement;

                                                                                }

                                                                                j++;

                                                                      }

                                                                      listsFound++;

                                                                      a++;

                                                                      allListElement = e.mxmlChildren as ListElement;

                                                            }

                                                            i++;

                                                  }

                                                  listsFound++;

                                        }

                                        elem = elem.getNextSibling();

                              }

 

 

                              // determine what the bullet text should be

                              var listItem:ListItemElement = new ListItemElement();

                              var bulletText:String = "";

                              var markerLength:int = 0;

                              var listStartIndex:int = 0;

                              var listFlowLine:TextFlowLine;

                              var listLine:TextLine;

                              var bulletLine:TextLine;

                              for (i=0; i<listsFound; i++)

                              {

                                        listElement = allListElement as ListElement;

                                        listItem = listElement.getChildAt(0) as ListItemElement;

                                        bulletText = listElement.computeListItemText(listItem, listItem.computedListMarkerFormat());

                                        markerLength = bulletText.length + 1;

                                        // find the TextFlowLine for the list start

                                        listStartIndex = listElement.getElementRelativeStart(tf);

                                        listFlowLine = tf.flowComposer.findLineAtPosition(listStartIndex);

                                        listLine = listFlowLine.getTextLine();

                                        bulletLine = listLine.getChildAt(0) as TextLine;

 

                              }

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
New Here ,
Apr 05, 2012 Apr 05, 2012

Copy link to clipboard

Copied

Thanks for your answer, but I need something else

for example I've had next text in RTF

111

*222

*333

*444

555

Where 222, 333, 444 are list element

I've select from 222 to 444 and press button

Next code are runing

var selState : SelectionState = new SelectionState(editor.textFlow, editor.selectionAnchorPosition, editor.selectionActivePosition);

var elem:FlowElement = selState.textFlow.getChildAt(0);

So, I've expect get first item from selection, but I've got first item of the textflow - paragraph 111.

Where did I wrong?

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
New Here ,
Apr 05, 2012 Apr 05, 2012

Copy link to clipboard

Copied

As I see SelectionState doesn't work correctly

The SelectionState class represents a selection in a text flow.

But in any case SelectionState return all textFlow. So, this is bug

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
Apr 05, 2012 Apr 05, 2012

Copy link to clipboard

Copied

LATEST

There will be only one textFlow in your case. It's the container of all the text elements. The selection state represents the selection in 'that' text flow.

The selection state will record the position information of your selection. You should get use the position information to retrieve your text flow elements

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