Files
nenya/src/as/com/threerings/flex/ChatInput.as
T
Ray Greenwell cbe1f76632 It's the return of the chat prompter!
What's this white box on the control bar?
Now it says "type to chat" right in there when empty and unfocused.
My life is empty and unfocused, checking this in at 11:15 on friday night.
Things like this were tried in the past, and were always screwing up
and getting in the way of chatting or using the room. This is a skin,
not actual text, so it's more fuckup-proof.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@633 ed5b42cb-e716-0410-a449-f6a68f950b19
2008-08-16 06:14:41 +00:00

54 lines
1.3 KiB
ActionScript

//
// $Id$
package com.threerings.flex {
import flash.events.FocusEvent;
import mx.controls.TextInput;
/**
* A special TextInput for entering Chat. One of these is used in ChatControl.
*
* A standard TextInput has the stupid behavior of selecting all the text when it receives
* focus. Disable that so that we can receive focus and people can type and we don't blow away
* whatever they had before.
*/
public class ChatInput extends TextInput
{
public function ChatInput ()
{
styleName = "chatInput";
width = 147;
showPrompt(true);
}
protected function showPrompt (show :Boolean) :void
{
setStyle("backgroundImage", (show && ("" == text)) ? PROMPT : undefined);
}
override protected function focusInHandler (event :FocusEvent) :void
{
var oldValue :Boolean = textField.selectable;
textField.selectable = false;
try {
super.focusInHandler(event);
} finally {
textField.selectable = oldValue;
}
showPrompt(false);
}
override protected function focusOutHandler (event :FocusEvent) :void
{
super.focusOutHandler(event);
showPrompt(true);
}
[Embed(source="typetochat.png")]
protected static const PROMPT :Class;
}
}