Don't use parentChanged() to track whether we're onscreen or not,
it's unreliable. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@352 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -68,6 +68,9 @@ public class ChatControl extends HBox
|
|||||||
_txt.height = height;
|
_txt.height = height;
|
||||||
_but.height = height;
|
_but.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addEventListener(Event.ADDED_TO_STAGE, handleAddRemove);
|
||||||
|
addEventListener(Event.REMOVED_FROM_STAGE, handleAddRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,26 +107,6 @@ public class ChatControl extends HBox
|
|||||||
_txt.setStyle("backgroundColor", color);
|
_txt.setStyle("backgroundColor", color);
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function parentChanged (p :DisplayObjectContainer) :void
|
|
||||||
{
|
|
||||||
super.parentChanged(p);
|
|
||||||
|
|
||||||
if (p != null) {
|
|
||||||
// set up any already-configured text
|
|
||||||
_txt.text = _curLine;
|
|
||||||
|
|
||||||
// request focus
|
|
||||||
callLater(function () :void {
|
|
||||||
_txt.setFocus();
|
|
||||||
});
|
|
||||||
_controls.push(this);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
_curLine = _txt.text;
|
|
||||||
ArrayUtil.removeAll(_controls, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles FlexEvent.ENTER and the action from the send button.
|
* Handles FlexEvent.ENTER and the action from the send button.
|
||||||
*/
|
*/
|
||||||
@@ -144,6 +127,27 @@ public class ChatControl extends HBox
|
|||||||
_txt.text = "";
|
_txt.text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles Event.ADDED_TO_STAGE and Event.REMOVED_FROM_STAGE.
|
||||||
|
*/
|
||||||
|
protected function handleAddRemove (event :Event) :void
|
||||||
|
{
|
||||||
|
if (event.type == Event.ADDED_TO_STAGE) {
|
||||||
|
// set up any already-configured text
|
||||||
|
_txt.text = _curLine;
|
||||||
|
|
||||||
|
// request focus
|
||||||
|
callLater(function () :void {
|
||||||
|
_txt.setFocus();
|
||||||
|
});
|
||||||
|
_controls.push(this);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_curLine = _txt.text;
|
||||||
|
ArrayUtil.removeAll(_controls, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Our client-side context. */
|
/** Our client-side context. */
|
||||||
protected var _ctx :CrowdContext;
|
protected var _ctx :CrowdContext;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user