Removed longstanding hack, make this prompt image a style.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@764 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2009-01-23 02:13:52 +00:00
parent da084e2c0c
commit 7db745258e
2 changed files with 27 additions and 5 deletions
+27 -5
View File
@@ -7,6 +7,11 @@ import flash.events.FocusEvent;
import mx.controls.TextInput;
/**
* The class name of an image to use as the input prompt.
*/
[Style(name="prompt", type="Class")]
/**
* A special TextInput for entering Chat. One of these is used in ChatControl.
*
@@ -18,14 +23,34 @@ public class ChatInput extends TextInput
{
public function ChatInput ()
{
styleName = "chatInput";
width = 147;
showPrompt(true);
}
override public function stylesInitialized () :void
{
super.stylesInitialized();
checkShowPrompt();
}
override public function styleChanged (styleProp :String) :void
{
super.styleChanged(styleProp);
if (styleProp == "prompt") {
checkShowPrompt();
}
}
protected function checkShowPrompt () :void
{
showPrompt(focusManager == null || focusManager.getFocus() != this);
}
protected function showPrompt (show :Boolean) :void
{
setStyle("backgroundImage", (show && ("" == text)) ? PROMPT : undefined);
setStyle("backgroundImage", (show && ("" == text)) ? getStyle("prompt") : undefined);
}
override protected function focusInHandler (event :FocusEvent) :void
@@ -46,8 +71,5 @@ public class ChatInput extends TextInput
super.focusOutHandler(event);
showPrompt(true);
}
[Embed(source="typetochat.png")]
protected static const PROMPT :Class;
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 B