From 7db745258e231198935585741e57623eae9a5ae2 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Fri, 23 Jan 2009 02:13:52 +0000 Subject: [PATCH] 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 --- src/as/com/threerings/flex/ChatInput.as | 32 ++++++++++++++++++---- src/as/com/threerings/flex/typetochat.png | Bin 400 -> 0 bytes 2 files changed, 27 insertions(+), 5 deletions(-) delete mode 100644 src/as/com/threerings/flex/typetochat.png diff --git a/src/as/com/threerings/flex/ChatInput.as b/src/as/com/threerings/flex/ChatInput.as index 4749b975..ff156a4d 100644 --- a/src/as/com/threerings/flex/ChatInput.as +++ b/src/as/com/threerings/flex/ChatInput.as @@ -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; } } diff --git a/src/as/com/threerings/flex/typetochat.png b/src/as/com/threerings/flex/typetochat.png deleted file mode 100644 index 5cd2807dd5022c7634de9e297cdbbae4271e4612..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 400 zcmV;B0dM|^P)X1^@s6F+0qb00004XF*Lt006JZ zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUzB1uF+RCwC# znn4nSFbGA(@dCY3@6~nh)f@E)bn7^x2_ZI#?`^6r5E{S0IEt!H042<90U#nkM1Y6@ z5D_3EXn-Zf=>7Q~JqM7A`Dx|&HP`dTTKnni`H&$*wAqZSFD%@kovCrY{#3)y`pvRU zjiEcaovr8bIm<6McQy8Oh)NVu(yimO>gJ7+yPi06O!Y~zlO8L5L?x2V9VEf?l3eT; znX5FETep=crw!JQ(OQd8MD)K3?yB@OoJqV3hLMC*A; zjPJdhl@lY!c01&z%r~0(Kej$<Cy*MvkguOU?O9t17^`?ULj?Pn#hi_**fV?rn un~l&)B?3eQfQSGQ0U`oK1W>|HfB^t917I^W2O5+B0000