Skip to main content
Known Participant
Nov 24, 2009 9:55 PM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

2 replies

Adobe Employee
Nov 24, 2009 10:45 PM UTC

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.

Translate
viatroposAuthor
Known Participant
Nov 24, 2009 10:51 PM UTC

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;

     }

}

Translate