Merge pull request #16 from gravitystorm/documentation
[potlatch2.git] / net / systemeD / controls / PromptingTextInputWarning.as
1 package net.systemeD.controls {
2         import flexlib.controls.PromptingTextInput;
3         import flash.display.DisplayObject;
4         import mx.controls.Image;
5
6     /**
7     * The PromptingTextInputWarning is a custom PromptingTextInput component that highlights values containing semicolons.
8     * It does so using colour and a warning icon. Simply use in place of a flexlib PromptingTextInput component.
9     *
10     * @see DataGridWarningField
11     */
12         public class PromptingTextInputWarning extends PromptingTextInput {
13
14                 private var _image:Image;
15                 [Embed(source="../../../embedded/warning.png")] private var warningIcon:Class;
16
17                 function PromptingTextInputWarning():void {
18                         super();
19                 }
20
21                 override protected function createChildren():void {
22                         super.createChildren();
23                         _image = new Image();
24                         _image.source = warningIcon;
25                         _image.width = 16;
26                         _image.height = 16;
27                         addChild(DisplayObject(_image));
28                 }
29
30                 override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
31                         super.updateDisplayList(unscaledWidth, unscaledHeight);
32                         if (text && text.indexOf(';')>-1) {
33                                 setStyle('color',0xFF0000);
34                                 _image.visible=true;
35                                 _image.x = width -_image.width -5;
36                                 _image.y = height-_image.height-3;
37                                 _image.toolTip = "The tag contains more than one value - please check";
38                                 textField.width = width-_image.width-5;
39                         } else {
40                                 setStyle('color',0);
41                                 _image.visible=false;
42                         }
43                 }
44         }
45 }