@Muzak,

Again... you should start tutoring and I will be your first student. :-)

Cor

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Muzak
Sent: zondag 29 maart 2009 17:30
To: Flash Coders List
Subject: Re: [Flashcoders] ?: how to prevent users to copy text from
aTextArea?

That depends..
If you have a component-heavy application with your own custom styles for
instance, it might be better to use a TextArea.
Or you could take it a step further and make this into a new component (and
even make it an mxp for distribution).

Then again, if all you need is one (and one only) non-selectable textfield,
sure grab a TextField and ScrollBar and move on :)

I mearly wanted to present a better solution (IMO) than overlaying a
TextArea with a shape, which is to actually fix what seems to 
be broke.

regards,
Muzak

----- Original Message ----- 
From: "Cor" <[email protected]>
To: "'Flash Coders List'" <[email protected]>
Sent: Sunday, March 29, 2009 1:00 PM
Subject: RE: [Flashcoders] ?: how to prevent users to copy text from
aTextArea?


> Just interested.
> Is all this worth the hassle?
> I mean instead using a TextArea, I would go for a normal TextField and a
> custom scrollbar all in 1 movieclip.
> And set the needs.
>
> Cor.
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Muzak
> Sent: zondag 29 maart 2009 1:20
> To: Flash Coders List
> Subject: Re: [Flashcoders] ?: how to prevent users to copy text from
> aTextArea?
>
>
> The problem seems to be that TextArea uses the "enabled" value to set the
> inner textField's selectable property value.
>
>  protected function updateTextFieldType():void {
>   textField.type = (enabled && _editable) ? TextFieldType.INPUT :
> TextFieldType.DYNAMIC;
>   textField.selectable = enabled;
>   textField.wordWrap = _wordWrap;
>   textField.multiline = true;
>  }
>
> So each time the updateTextFieldType() method is called, no matter what
you
> set TextArea.textField.selectable to, it will revert to
> the TextArea.enabled value.
> That's why :
>
>    details_ta.textField.selectable = false;
>
> doesn't really work.
>
> So it's not really a bug, just a (very) bad decision.
> Why it was done that way, who knows..
>
> To get the TextArea to work the way you want, you can extend it and
override
> the updateTextFieldType() method and add a selectable
> property, like so:
>
> package {
>
> import fl.controls.TextArea;
> import flash.text.TextFieldType;
>
> public class TextArea2 extends TextArea {
>
>  private var _selectable:Boolean = true;
>
>  override protected function updateTextFieldType():void {
>   textField.type = (enabled && _editable) ? TextFieldType.INPUT :
> TextFieldType.DYNAMIC;
>   textField.selectable = _selectable;
>   textField.wordWrap = _wordWrap;
>   textField.multiline = true;
>  }
>
>  public function get selectable():Boolean {
>   return _selectable;
>  }
>  public function set selectable(value:Boolean):void {
>   _selectable = value;
>   super.textField.selectable = value;
>   updateTextFieldType()
>  }
>
> }
> }
>
>
> Tested with the code you provided earlier (normal TextArea on stage):
>
> package {
>
> import flash.display.Sprite;
> import fl.controls.TextArea;
> import flash.text.TextField;
> import flash.events.Event;
> import TextArea2;
>
> public class TestTextArea extends Sprite {
>
>  public var details_ta:TextArea;
>  public var details2_ta:TextArea2;
>
>  public function TestTextArea() {
>   addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
>   init();
>  }
>
>  private function init():void {
>   trace("TestTextArea ::: init");
>   details2_ta = new TextArea2();
>   details2_ta.selectable = false;
>   details2_ta.x = 220;
>   details2_ta.y = 10;
>   details2_ta.width = 200;
>   details2_ta.height = 100;
>   addChild(details2_ta);
>  }
>
>  private function addedToStageHandler(evt:Event):void {
>   trace("TestTextArea ::: addedToStageHandler");
>   var msg:String = "<b>Lorem ipsum dolor sit amet,</b> consectetuer
> adipiscing elit.";
>   details_ta.htmlText = msg;
>   details2_ta.htmlText = msg;
>  }
>
> }
> }
>
> regards,
> Muzak
>

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.278 / Virus Database: 270.11.31/2028 - Release Date: 03/28/09
07:16:00

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to