Skip to main content
Known Participant
November 24, 2009
Question

How do you do basic Tabs (where "\t" = 4 spaces)?

  • November 24, 2009
  • 1 reply
  • 470 views

Is there an easy way to say "when I push tab, insert a space 4 spaces wide", such that when I press delete, it deletes it as if it were one object?

There's gotta be something simple I'm missing.

Thanks.

This topic has been closed for replies.

1 reply

Adobe Employee
November 24, 2009

You could figure out how wide the space is, multiply by 4, and set up tab stops at those locations, then insert tabs in the text. Those will delete as a single unit. I guess you could also insert a space with a tracking value attached that makes it larger. So you'd insert the space, then call applyFormat to set the tracking value.

viatroposAuthor
Known Participant
November 24, 2009

There it is!!! Thank you so much, it makes sense now:

protected function editor_keyDownHandler(event:KeyboardEvent):void

{

     var position:Number;

     var bounds:Point = TextUtil.getSelectedLineBoundsPosition(editor.textDisplay);

    

     if (event.keyCode == Keyboard.TAB)

     {

          position = editor.selectionAnchorPosition - bounds.x + 10;

          editor.textFlow.tabStops = "s" + position.toString();

          editor.insertText("\t");

          editor.textFlow.tabStops = null;

     }

}