Mostly kinda fixed up keyboard issues for EZGames.

They can add their keyboard listeners directly to the GameControl object
to receive global key events.

There are strange focus weirdnesses on the flex side- sometimes you have
focus with no focus highlight and sometimes you don't have focus and you
do have the highlight. Punting, rather than spending more hours on this.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@138 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Ray Greenwell
2007-01-06 01:44:05 +00:00
parent 3b08974f73
commit 00e2c45f01
4 changed files with 137 additions and 14 deletions
@@ -1,27 +1,55 @@
package com.threerings.ezgame.client {
import flash.display.InteractiveObject;
import flash.display.Loader;
import flash.geom.Rectangle;
import mx.core.mx_internal;
import mx.core.IFlexDisplayObject;
import mx.core.IInvalidating;
import mx.managers.IFocusManagerComponent;
import mx.skins.ProgrammaticSkin;
import com.threerings.util.MediaContainer;
// TODO: there are focus issues in here that need dealing with.
//
// 1) The focus rectangle is drawn at the wrong size in scrolling games
// 2) We can get focus without having the pink focus rectangle...
// 3) When the mouse leaves the flash player and returns, this
// damn thing doesn't seem to grip onto the focus.
//
public class GameContainer extends MediaContainer
implements IFocusManagerComponent
{
public function GameContainer (url :String)
{
super(url);
tabEnabled = true; // turned off by Container
// focusRect = true; // we need the focus rect
}
override public function setFocus () :void
override protected function adjustFocusRect (obj :DisplayObject = null) :void
{
super.setFocus();
if (systemManager.stage.focus == this) {
// TODO
//systemManager.stage.focus = InteractiveObject(Loader(_media).content);
systemManager.stage.focus = Loader(_media);
super.adjustFocusRect(obj);
// TODO: this is probably all wrong
var focusObj :IFlexDisplayObject =
IFlexDisplayObject(mx_internal::getFocusObject());
if (focusObj) {
var r :Rectangle = transform.pixelBounds;
focusObj.setActualSize(r.width - 2, r.height - 2);
focusObj.move(0, 0);
if (focusObj is IInvalidating) {
IInvalidating(focusObj).validateNow();
} else if (focusObj is ProgrammaticSkin) {
ProgrammaticSkin(focusObj).validateNow();
}
}
}
}