瀏覽代碼

Added ability to register focus child without adding it to the UI element, separete groups of focusable elements now tab through seamlessly in IDE prop sheets, moved some more IDE inputs to be tabbable

Ivan Safrin 10 年之前
父節點
當前提交
14ff32c986

+ 5 - 5
IDE/Contents/Include/PolycodeProps.h

@@ -54,7 +54,7 @@ class PropProp : public UIElement {
 
 class Vector3Prop : public PropProp {
     public:
-        Vector3Prop(String caption);
+        Vector3Prop(String caption, UIElement *focusParent);
         ~Vector3Prop();
         void handleEvent(Event *event);
         void set(const Vector3 &position);
@@ -80,7 +80,7 @@ class Vector3Prop : public PropProp {
 
 class Vector2Prop : public PropProp {
 	public:
-		Vector2Prop(String caption);
+		Vector2Prop(String caption, UIElement *focusParent);
 		~Vector2Prop();		
 		void handleEvent(Event *event);
 		void set(Vector2 position);
@@ -120,7 +120,7 @@ class SliderProp : public PropProp {
 
 class ButtonProp : public PropProp {
     public:
-        ButtonProp(const String &caption);
+        ButtonProp(const String &caption, UIElement *focusParent);
         ~ButtonProp();
         void setPropWidth(Number width);
         UIButton *getButton();
@@ -133,7 +133,7 @@ class ButtonProp : public PropProp {
 
 class NumberProp : public PropProp {
 	public:
-		NumberProp(String caption);
+		NumberProp(String caption, UIElement *focusParent);
 		~NumberProp();		
 		void handleEvent(Event *event);
 		void set(Number number);
@@ -265,7 +265,7 @@ class CustomProp : public PropProp {
 
 class StringProp : public PropProp {
 	public:
-		StringProp(String caption);
+		StringProp(String caption, UIElement *focusParent);
 		~StringProp();		
 		void handleEvent(Event *event);
 		void set(String str);

+ 6 - 6
IDE/Contents/Source/PolycodeMaterialEditor.cpp

@@ -44,7 +44,7 @@ PostEditorPane::PostEditorPane(ResourcePool *resourcePool) : UIElement() {
 	baseProps = new PropSheet("EFFECT OPTIONS", "");
 	propList->addPropSheet(baseProps);
 
-	nameProp = new StringProp("Name");
+	nameProp = new StringProp("Name", this);
 	baseProps->addProp(nameProp);
 	nameProp->addEventListener(this, Event::CHANGE_EVENT);
 	
@@ -220,7 +220,7 @@ CubemapEditorPane::CubemapEditorPane(ResourcePool *resourcePool) : UIElement() {
 	PropSheet *baseProps1 = new PropSheet("CUBEMAP OPTIONS", "");
 	propList->addPropSheet(baseProps1);
 
-	nameProp = new StringProp("Name");
+	nameProp = new StringProp("Name", this);
 	baseProps1->addProp(nameProp);
 	
 	baseProps1->propHeight = 70;
@@ -362,7 +362,7 @@ ShaderEditorPane::ShaderEditorPane(ResourcePool *resourcePool) : UIElement() {
 	PropSheet *baseProps = new PropSheet("SHADER SETTINGS", "");
 	propList->addPropSheet(baseProps);
 	
-	nameProp = new StringProp("Name");
+	nameProp = new StringProp("Name", this);
 	baseProps->addProp(nameProp);	
 	nameProp->addEventListener(this, Event::CHANGE_EVENT);	
 	
@@ -379,11 +379,11 @@ ShaderEditorPane::ShaderEditorPane(ResourcePool *resourcePool) : UIElement() {
 	baseProps->addProp(fragmentProgramProp);	
 	fragmentProgramProp->addEventListener(this, Event::CHANGE_EVENT);	
 	
-	pointLightsProp = new NumberProp("Num point lights");
+	pointLightsProp = new NumberProp("Num point lights", this);
 	baseProps->addProp(pointLightsProp);
 	pointLightsProp->addEventListener(this, Event::CHANGE_EVENT);
 
-	spotLightsProp = new NumberProp("Num spotlights");
+	spotLightsProp = new NumberProp("Num spotlights", this);
 	baseProps->addProp(spotLightsProp);	
 	spotLightsProp->addEventListener(this, Event::CHANGE_EVENT);
 
@@ -860,7 +860,7 @@ MaterialEditorPane::MaterialEditorPane() : UIElement() {
 	PropSheet *baseProps = new PropSheet("MATERIAL SETTINGS", "");
 	propList->addPropSheet(baseProps);
 	
-	nameProp = new StringProp("Name");
+	nameProp = new StringProp("Name", this);
 	baseProps->addProp(nameProp);	
 	nameProp->addEventListener(this, Event::CHANGE_EVENT);
 		

+ 70 - 62
IDE/Contents/Source/PolycodeProps.cpp

@@ -353,9 +353,10 @@ PropProp::~PropProp() {
 
 }
 
-ButtonProp::ButtonProp(const String &caption) : PropProp("", "ButtonProp") {
+ButtonProp::ButtonProp(const String &caption, UIElement *focusParent) : PropProp("", "ButtonProp") {
     button = new UIButton(caption, 100);
-    addFocusChild(button);
+    addChild(button);
+    focusParent->registerFocusChild(button);
     setHeight(25);
 }
 
@@ -372,7 +373,7 @@ void ButtonProp::setPropWidth(Number width) {
 }
 
 
-Vector3Prop::Vector3Prop(String caption) : PropProp(caption, "Vector3") {
+Vector3Prop::Vector3Prop(String caption, UIElement *focusParent) : PropProp(caption, "Vector3") {
     
     xInput = NULL;
     yInput = NULL;
@@ -380,38 +381,41 @@ Vector3Prop::Vector3Prop(String caption) : PropProp(caption, "Vector3") {
     
 	labelX = new UILabel("X:", 11);
 	labelX->color.a = 1.0;
-	propContents->addFocusChild(labelX);
+	propContents->addChild(labelX);
 	labelX->setPosition(-20, 5);
     
 	labelY = new UILabel("Y:", 11);
 	labelY->color.a = 1.0;
-	propContents->addFocusChild(labelY);
+	propContents->addChild(labelY);
 	labelY->setPosition(-20, 25);
 
     labelZ = new UILabel("Z:", 11);
 	labelZ->color.a = 1.0;
-	propContents->addFocusChild(labelZ);
+	propContents->addChild(labelZ);
 	labelZ->setPosition(-20, 45);
     
 	xInput = new UITextInput(false, 50, 12);
 	xInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 	xInput->setText("0");
 	xInput->setNumberOnly(true);
-	propContents->addFocusChild(xInput);
+	propContents->addChild(xInput);
+    focusParent->registerFocusChild(xInput);
 	xInput->setPosition(0, 0);
 
    	yInput = new UITextInput(false, 50, 12);
 	yInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 	yInput->setText("0");
 	yInput->setNumberOnly(true);
-	propContents->addFocusChild(yInput);
+	propContents->addChild(yInput);
+    focusParent->registerFocusChild(yInput);
 	yInput->setPosition(0, 20);
 
     zInput = new UITextInput(false, 50, 12);
 	zInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 	zInput->setText("0");
 	zInput->setNumberOnly(true);
-	propContents->addFocusChild(zInput);
+	propContents->addChild(zInput);
+    focusParent->registerFocusChild(zInput);
 	zInput->setPosition(0, 40);
 
 	setHeight(65);
@@ -463,16 +467,16 @@ Vector3Prop::~Vector3Prop() {
     
 }
 
-Vector2Prop::Vector2Prop(String caption) : PropProp(caption, "Vector2") {
+Vector2Prop::Vector2Prop(String caption, UIElement *focusParent) : PropProp(caption, "Vector2") {
 
 	labelX = new UILabel("X:", 11);
 	labelX->color.a = 1.0;
-	propContents->addFocusChild(labelX);
+	propContents->addChild(labelX);
 	labelX->setPosition(-20, 6);	
 
 	labelY = new UILabel("Y:", 11);
 	labelY->color.a = 1.0;
-	propContents->addFocusChild(labelY);
+	propContents->addChild(labelY);
 	labelY->setPosition(60, 6);	
 	
 	positionX = NULL;
@@ -482,14 +486,16 @@ Vector2Prop::Vector2Prop(String caption) : PropProp(caption, "Vector2") {
 	positionX->addEventListener(this, UIEvent::CHANGE_EVENT);
 	positionX->setText("0");
 	positionX->setNumberOnly(true);
-	propContents->addFocusChild(positionX);
+	propContents->addChild(positionX);
+    focusParent->registerFocusChild(positionX);
 	positionX->setPosition(0, 0);
 
 	positionY = new UITextInput(false, 50, 12);
 	positionY->setText("0");
 	positionY->addEventListener(this, UIEvent::CHANGE_EVENT);	
 	positionY->setNumberOnly(true);
-	propContents->addFocusChild(positionY);
+	propContents->addChild(positionY);
+    focusParent->registerFocusChild(positionY);
 	positionY->setPosition(80, 0);
 
 	setHeight(25);
@@ -758,12 +764,13 @@ String CustomProp::getKey() {
 }
 
 
-StringProp::StringProp(String caption) : PropProp(caption, "String") {
+StringProp::StringProp(String caption, UIElement *focusParent) : PropProp(caption, "String") {
 
 	stringEntry = new UITextInput(false, 150, 12);
 	stringEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
 	stringEntry->setText("");
-	propContents->addFocusChild(stringEntry);
+	propContents->addChild(stringEntry);
+    focusParent->registerFocusChild(stringEntry);
 	stringEntry->setPosition(0, 0);
 	setHeight(25);
 }
@@ -866,13 +873,14 @@ SliderProp::~SliderProp() {
 
 }
 
-NumberProp::NumberProp(String caption) : PropProp(caption, "Number") {
+NumberProp::NumberProp(String caption, UIElement *focusParent) : PropProp(caption, "Number") {
 
 	numberEntry = new UITextInput(false, 50, 20);
 	numberEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
 	numberEntry->setText("0");
 	numberEntry->setNumberOnly(true);
-	propContents->addFocusChild(numberEntry);
+	propContents->addChild(numberEntry);
+    focusParent->registerFocusChild(numberEntry);
 	numberEntry->setPosition(0, 2);
 
 	setHeight(25);
@@ -1869,7 +1877,7 @@ void RenderTargetProp::handleEvent(Event *event) {
 ShaderPassesSheet::ShaderPassesSheet(ResourcePool *resourcePool) : PropSheet("SHADER PASSES", "shaderPasses") {
     this->resourcePool = resourcePool;
 	propHeight = 70;
-	addButton = new ButtonProp("Add Shader Pass");
+	addButton = new ButtonProp("Add Shader Pass", this);
 	addButton->getButton()->addEventListener(this, UIEvent::CLICK_EVENT);
     addProp(addButton);
 	
@@ -1960,7 +1968,7 @@ void ShaderPassesSheet::handleEvent(Event *event) {
 }
 
 TargetBindingsSheet::TargetBindingsSheet() : PropSheet("TEXTURE BINDINGS", "targetBindings") {
-	addButton = new ButtonProp("Add Render Target");
+	addButton = new ButtonProp("Add Render Target", this);
 	addButton->getButton()->addEventListener(this, UIEvent::CLICK_EVENT);
     addProp(addButton);
 	customUndoHandler = true;
@@ -2046,7 +2054,7 @@ void TargetBindingsSheet::handleEvent(Event *event) {
 
 RenderTargetsSheet::RenderTargetsSheet() : PropSheet("RENDER TARGETS", "renderTargets") {
 	propHeight = 70;
-	addButton = new ButtonProp("Add Render Target");
+	addButton = new ButtonProp("Add Render Target", this);
 	addButton->getButton()->addEventListener(this, UIEvent::CLICK_EVENT);
     addProp(addButton);
     
@@ -2136,7 +2144,7 @@ void RenderTargetsSheet::handleEvent(Event *event) {
 
 EntityPropSheet::EntityPropSheet() : PropSheet("CUSTOM PROPERTIES", "entityProps"){
 	
-    addButtonProp = new ButtonProp("Add Property");
+    addButtonProp = new ButtonProp("Add Property", this);
     addProp(addButtonProp);
     addButtonProp->getButton()->addEventListener(this, UIEvent::CLICK_EVENT);
 
@@ -2321,7 +2329,7 @@ void ShaderOptionsSheet::setOptionsFromParams(std::vector<ProgramParam> &params)
 					case ProgramParam::PARAM_NUMBER:
 					{
 						String paramName = params[i].name;
-						NumberProp *numberProp = new NumberProp(paramName);
+						NumberProp *numberProp = new NumberProp(paramName, this);
 						addProp(numberProp);
 												
                         LocalShaderParam *param = binding->getLocalParamByName(params[i].name);
@@ -2487,13 +2495,13 @@ void ShaderTexturesSheet::setShader(Shader *shader, Material *material, ShaderBi
 TransformSheet::TransformSheet() : PropSheet("TRANSFORM", "entity_transform") {
     entity = NULL;
     
-    positionProp = new Vector3Prop("Position");
+    positionProp = new Vector3Prop("Position", this);
     addProp(positionProp);
     
-    scaleProp = new Vector3Prop("Scale");
+    scaleProp = new Vector3Prop("Scale", this);
     addProp(scaleProp);
     
-    rotationProp = new Vector3Prop("Rotation");
+    rotationProp = new Vector3Prop("Rotation", this);
     addProp(rotationProp);
     
     propHeight = 235;
@@ -2560,16 +2568,16 @@ ParticleEmitterSheet::ParticleEmitterSheet() : PropSheet("PARTICLE EMITTER", "pa
     typeProp->comboEntry->addComboItem("Quad");
     addProp(typeProp);
 
-    countProp = new NumberProp("Count");
+    countProp = new NumberProp("Count", this);
     addProp(countProp);
     
-    lifetimeProp = new NumberProp("Lifetime");
+    lifetimeProp = new NumberProp("Lifetime", this);
     addProp(lifetimeProp);
 
-    particleSizeProp = new NumberProp("Size");
+    particleSizeProp = new NumberProp("Size", this);
     addProp(particleSizeProp);
     
-    particleSpeedProp = new NumberProp("Speed");
+    particleSpeedProp = new NumberProp("Speed", this);
     addProp(particleSpeedProp);
     
     worldParticlesProp = new BoolProp("World space");
@@ -2578,25 +2586,25 @@ ParticleEmitterSheet::ParticleEmitterSheet() : PropSheet("PARTICLE EMITTER", "pa
     loopingProp = new BoolProp("Loop");
     addProp(loopingProp);
     
-    particleRotaionProp = new Vector3Prop("Rotation");
+    particleRotaionProp = new Vector3Prop("Rotation", this);
     addProp(particleRotaionProp);
     
-    gravityProp = new Vector3Prop("Gravity");
+    gravityProp = new Vector3Prop("Gravity", this);
     addProp(gravityProp);
     
-    directionProp = new Vector3Prop("Direction");
+    directionProp = new Vector3Prop("Direction", this);
     addProp(directionProp);
 
-    deviationProp = new Vector3Prop("Deviation");
+    deviationProp = new Vector3Prop("Deviation", this);
     addProp(deviationProp);
 
-    sizeProp = new Vector3Prop("Emitter size");
+    sizeProp = new Vector3Prop("Emitter size", this);
     addProp(sizeProp);
 
     perlinProp = new BoolProp("Movement noise");
     addProp(perlinProp);
     
-    perlinSizeProp = new Vector3Prop("Noise amount");
+    perlinSizeProp = new Vector3Prop("Noise amount", this);
     addProp(perlinSizeProp);
 
     useColorCurvesProp = new BoolProp("Use color curves");
@@ -2703,7 +2711,7 @@ SceneLightSheet::SceneLightSheet() : PropSheet("LIGHT", "scene_light") {
     typeProp->comboEntry->addComboItem("Spot");
     addProp(typeProp);
     
-    importanceProp = new NumberProp("Importance");
+    importanceProp = new NumberProp("Importance", this);
     addProp(importanceProp);
     
     lightColorProp = new ColorProp("Light color");
@@ -2712,7 +2720,7 @@ SceneLightSheet::SceneLightSheet() : PropSheet("LIGHT", "scene_light") {
     specularColorProp = new ColorProp("Specular color");
     addProp(specularColorProp);
     
-    intensityProp = new NumberProp("Intensity");
+    intensityProp = new NumberProp("Intensity", this);
     addProp(intensityProp);
     
     constantAttenuationProp = new SliderProp("Constant att.", 0.0, 1.0);
@@ -2736,7 +2744,7 @@ SceneLightSheet::SceneLightSheet() : PropSheet("LIGHT", "scene_light") {
     shadowMapFOVProp = new SliderProp("Shadow FOV", 1.0, 180.0);
     addProp(shadowMapFOVProp);
     
-    shadowResolutionProp = new NumberProp("Shadowmap res.");
+    shadowResolutionProp = new NumberProp("Shadowmap res.", this);
     addProp(shadowResolutionProp);
 
     propHeight = 365;
@@ -2911,19 +2919,19 @@ ScenePrimitiveSheet::ScenePrimitiveSheet() : PropSheet("PRIMITIVE", "scene_primi
     
     addProp(typeProp);
     
-    option1Prop = new NumberProp("");
+    option1Prop = new NumberProp("", this);
     addProp(option1Prop);
     
-    option2Prop = new NumberProp("");
+    option2Prop = new NumberProp("", this);
     addProp(option2Prop);
     
-    option3Prop = new NumberProp("");
+    option3Prop = new NumberProp("", this);
     addProp(option3Prop);
     
-    option4Prop = new NumberProp("");
+    option4Prop = new NumberProp("", this);
     addProp(option4Prop);
 
-    option5Prop = new NumberProp("");
+    option5Prop = new NumberProp("", this);
     addProp(option5Prop);
 
     propHeight = 240;
@@ -3200,10 +3208,10 @@ EntitySheet::EntitySheet() : PropSheet("ENTITY", "entity"){
     layersProp = new ComboProp("Layer");
     addProp(layersProp);
     
-	idProp = new StringProp("ID");
+	idProp = new StringProp("ID", this);
 	addProp(idProp);
 
-	tagProp = new StringProp("Tags (foo,bar)");
+	tagProp = new StringProp("Tags (foo,bar)", this);
 	addProp(tagProp);
 
 	colorProp = new ColorProp("Color");
@@ -3212,7 +3220,7 @@ EntitySheet::EntitySheet() : PropSheet("ENTITY", "entity"){
 	blendingProp = new ComboProp("Blend mode");
 	addProp(blendingProp);
     
-    bBoxProp = new Vector3Prop("Bounding box");
+    bBoxProp = new Vector3Prop("Bounding box", this);
 	addProp(bBoxProp);
     
     blendingProp->comboEntry->addComboItem("None");
@@ -3309,19 +3317,19 @@ CameraSheet::CameraSheet() : PropSheet("CAMERA", "camera") {
     enabled = false;
     camera = NULL;
     
-    exposureProp = new NumberProp("Exposure");
+    exposureProp = new NumberProp("Exposure", this);
     addProp(exposureProp);
 
-    nearClipPlane = new NumberProp("Near clip");
+    nearClipPlane = new NumberProp("Near clip", this);
     addProp(nearClipPlane);
     
-    farClipPlane = new NumberProp("Far clip");
+    farClipPlane = new NumberProp("Far clip", this);
     addProp(farClipPlane);
     
     orthoProp = new BoolProp("Orthographic");
     addProp(orthoProp);
 
-    fovProp = new NumberProp("FOV");
+    fovProp = new NumberProp("FOV", this);
     addProp(fovProp);
 
     orthoSizeTypeProp = new ComboProp("Size mode");
@@ -3332,10 +3340,10 @@ CameraSheet::CameraSheet() : PropSheet("CAMERA", "camera") {
     
     addProp(orthoSizeTypeProp);
     
-    orthoWidthProp = new NumberProp("Ortho width");
+    orthoWidthProp = new NumberProp("Ortho width", this);
     addProp(orthoWidthProp);
 
-    orthoHeightProp = new NumberProp("Ortho height");
+    orthoHeightProp = new NumberProp("Ortho height", this);
     addProp(orthoHeightProp);
     
     propHeight = 260;
@@ -3442,7 +3450,7 @@ SceneCurveSheet::SceneCurveSheet() : PropSheet("CURVE", "SceneCurve") {
     curve = NULL;
     enabled = false;
     
-    addPointProp = new ButtonProp("Add Curve Point");
+    addPointProp = new ButtonProp("Add Curve Point", this);
     addProp(addPointProp);
     addPointProp->getButton()->addEventListener(this, UIEvent::CLICK_EVENT);
 
@@ -3450,7 +3458,7 @@ SceneCurveSheet::SceneCurveSheet() : PropSheet("CURVE", "SceneCurve") {
     addProp(renderProp);
     renderProp->addEventListener(this, Event::CHANGE_EVENT);
 
-    numPointsProp = new NumberProp("Resolution");
+    numPointsProp = new NumberProp("Resolution", this);
     addProp(numPointsProp);
     numPointsProp->addEventListener(this, Event::CHANGE_EVENT);
 
@@ -3637,15 +3645,15 @@ SceneLabelSheet::SceneLabelSheet() : PropSheet("LABEL", "UILabel") {
 	label = NULL;
     enabled = false;
 	
-	caption = new StringProp("Contents");
+	caption = new StringProp("Contents", this);
 	caption->addEventListener(this, Event::CHANGE_EVENT);
 	addProp(caption);
 
-	size = new NumberProp("Size (px)");
+	size = new NumberProp("Size (px)", this);
 	size->addEventListener(this, Event::CHANGE_EVENT);
 	addProp(size);	
 
-    actualHeight = new NumberProp("Actual height");
+    actualHeight = new NumberProp("Actual height", this);
 	actualHeight->addEventListener(this, Event::CHANGE_EVENT);
 	addProp(actualHeight);
 
@@ -3757,7 +3765,7 @@ void SceneLabelSheet::handleEvent(Event *event) {
 LayerSheet::LayerSheet() : PropSheet("VISIBILITY LAYERS", "layers") {
     
     
-    addLayerProp = new ButtonProp("Add new layer");
+    addLayerProp = new ButtonProp("Add new layer", this);
     addProp(addLayerProp);
     addLayerProp->getButton()->addEventListener(this, UIEvent::CLICK_EVENT);
     
@@ -3837,7 +3845,7 @@ void LayerSheet::handleEvent(Event *event) {
 
 LinkedMaterialsSheet::LinkedMaterialsSheet() : PropSheet("LINKED RESOURCE POOLS", "linked_materials") {
     
-    addMaterialProp = new ButtonProp("Link resource pool");
+    addMaterialProp = new ButtonProp("Link resource pool", this);
     addProp(addMaterialProp);
     addMaterialProp->getButton()->addEventListener(this, UIEvent::CLICK_EVENT);
     
@@ -3958,11 +3966,11 @@ SoundSheet::SoundSheet() : PropSheet("SOUND", "sound") {
 	soundProp->addEventListener(this, Event::CHANGE_EVENT);
 	addProp(soundProp);
 	
-	referenceDistance = new NumberProp("Reference dist");
+	referenceDistance = new NumberProp("Reference dist", this);
 	referenceDistance->addEventListener(this, Event::CHANGE_EVENT);
 	addProp(referenceDistance);
     
-	maxDistance = new NumberProp("Max dist");
+	maxDistance = new NumberProp("Max dist", this);
 	maxDistance->addEventListener(this, Event::CHANGE_EVENT);
 	addProp(maxDistance);
     

+ 9 - 9
IDE/Contents/Source/PolycodeSpriteEditor.cpp

@@ -165,7 +165,7 @@ SpriteSheetEditor::SpriteSheetEditor(SpriteSet *sprite) : UIElement() {
     label->setPosition(120.0 - label->getWidth(), 68.0);
     
     uniformGridWidthInput = new UITextInput(false, 100.0, 12);
-    uniformOptions->addChild(uniformGridWidthInput);
+    uniformOptions->addFocusChild(uniformGridWidthInput);
     uniformGridWidthInput->setPosition(130.0, 65.0);
     uniformGridWidthInput->setText("32");
     uniformGridWidthInput->setNumberOnly(true);
@@ -175,7 +175,7 @@ SpriteSheetEditor::SpriteSheetEditor(SpriteSet *sprite) : UIElement() {
     label->setPosition(120.0 - label->getWidth(), 93.0);
     
     uniformGridHeightInput = new UITextInput(false, 100, 12);
-    uniformOptions->addChild(uniformGridHeightInput);
+    uniformOptions->addFocusChild(uniformGridHeightInput);
     uniformGridHeightInput->setPosition(130.0, 90);
     uniformGridHeightInput->setText("32");
     uniformGridHeightInput->setNumberOnly(true);
@@ -185,7 +185,7 @@ SpriteSheetEditor::SpriteSheetEditor(SpriteSet *sprite) : UIElement() {
     label->setPosition(120.0 - label->getWidth(), 68.0);
     
     minimumDistanceInput = new UITextInput(false, 30, 12);
-    detectOptions->addChild(minimumDistanceInput);
+    detectOptions->addFocusChild(minimumDistanceInput);
     minimumDistanceInput->setPosition(130.0, 65.0);
     minimumDistanceInput->setText("0");
     minimumDistanceInput->setNumberOnly(true);
@@ -794,7 +794,7 @@ SpriteStateEditorDetails::SpriteStateEditorDetails(SpriteSet *spriteSet) : UIEle
     addChild(label);
     
     fpsInput = new UITextInput(false, 50.0, 12.0);
-    addChild(fpsInput);
+    addFocusChild(fpsInput);
     fpsInput->setPosition(65.0, 40.0);
     fpsInput->addEventListener(this, UIEvent::CHANGE_EVENT);
     
@@ -803,7 +803,7 @@ SpriteStateEditorDetails::SpriteStateEditorDetails(SpriteSet *spriteSet) : UIEle
     addChild(label);
     
     scaleInput = new UITextInput(false, 50.0, 12.0);
-    addChild(scaleInput);
+    addFocusChild(scaleInput);
     scaleInput->setPosition(65.0, 65.0);
     scaleInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 
@@ -812,7 +812,7 @@ SpriteStateEditorDetails::SpriteStateEditorDetails(SpriteSet *spriteSet) : UIEle
     addChild(label);
     
     bBoxWidthInput = new UITextInput(false, 50.0, 12.0);
-    addChild(bBoxWidthInput);
+    addFocusChild(bBoxWidthInput);
     bBoxWidthInput->setPosition(65.0, 90.0);
     bBoxWidthInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 
@@ -821,7 +821,7 @@ SpriteStateEditorDetails::SpriteStateEditorDetails(SpriteSet *spriteSet) : UIEle
     addChild(label);
     
     bBoxHeightInput = new UITextInput(false, 50.0, 12.0);
-    addChild(bBoxHeightInput);
+    addFocusChild(bBoxHeightInput);
     bBoxHeightInput->setPosition(65.0, 115.0);
     bBoxHeightInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 
@@ -830,7 +830,7 @@ SpriteStateEditorDetails::SpriteStateEditorDetails(SpriteSet *spriteSet) : UIEle
     addChild(label);
     
     offsetXInput = new UITextInput(false, 50.0, 12.0);
-    addChild(offsetXInput);
+    addFocusChild(offsetXInput);
     offsetXInput->setPosition(65.0, 140.0);
     offsetXInput->addEventListener(this, UIEvent::CHANGE_EVENT);
     
@@ -839,7 +839,7 @@ SpriteStateEditorDetails::SpriteStateEditorDetails(SpriteSet *spriteSet) : UIEle
     addChild(label);
     
     offsetYInput = new UITextInput(false, 50.0, 12.0);
-    addChild(offsetYInput);
+    addFocusChild(offsetYInput);
     offsetYInput->setPosition(65.0, 165.0);
     offsetYInput->addEventListener(this, UIEvent::CHANGE_EVENT);
     

+ 3 - 1
Modules/Contents/UI/Include/PolyUIElement.h

@@ -60,7 +60,9 @@ namespace Polycode {
 			virtual void onLoseFocus() {}
 			virtual void onGainFocus() {}
 			
-			void addFocusChild(UIElement *element);			
+			void addFocusChild(UIElement *element);
+			void registerFocusChild(UIElement *element);
+			void unregisterFocusChild(UIElement *element);
 			void setFocusParent(UIElement *element);
 
 			MouseEventResult onMouseMove(const Ray &ray, int timestamp);

+ 18 - 1
Modules/Contents/UI/Source/PolyUIElement.cpp

@@ -403,6 +403,10 @@ UIElement::~UIElement() {
     
     Services()->getInput()->removeAllHandlersForListener(this);
 
+    if(focusParent) {
+        focusParent->unregisterFocusChild(this);
+    }
+    
 	if(UIElement::globalFocusedChild == this) {
 		UIElement::globalFocusedChild = NULL;
 	}
@@ -496,11 +500,24 @@ void UIElement::focusChild(UIElement *child) {
 	}	
 }
 
-void UIElement::addFocusChild(UIElement *element) {
+void UIElement::registerFocusChild(UIElement *element) {
     if(element->isFocusable()) {
         element->setFocusParent(this);
         focusChildren.push_back(element);
     }
+}
+
+void UIElement::unregisterFocusChild(UIElement *element) {
+    for(int i=0; i < focusChildren.size(); i++) {
+        if(focusChildren[i] == element) {
+            focusChildren.erase(focusChildren.begin()+i);
+            return;
+        }
+    }
+}
+
+void UIElement::addFocusChild(UIElement *element) {
+    registerFocusChild(element);
     addChild(element);
 }