Explorar el Código

Update focusing in UI module, focusable UI elements must now be explicitly added with addFocusChild. UI elements will now properly cycle focus when user presses tab key, updated IDE in most places to use addFocusChild

Ivan Safrin hace 10 años
padre
commit
b4b8130dad

+ 1 - 1
IDE/Contents/Include/PolycodeFontEditor.h

@@ -38,7 +38,7 @@ public:
 	
 protected:
 		
-	Entity *anchor;
+	UIElement *anchor;
 	UILabel *editorLabel;
 	UILabel *editorLabel2;
 	UILabel *editorLabel3;

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

@@ -46,7 +46,7 @@ class PropProp : public UIElement {
     
 		String propType;
 		UILabel *label;
-		Entity *propContents;				
+		UIElement *propContents;
 		
 		bool suppressChangeEvent;		
 		bool settingFromData;
@@ -491,7 +491,7 @@ class PropSheet : public UIElement {
 		String type;
 		
 		Number propHeight;				
-		Entity *contents;
+		UIElement *contents;
 		
 		UIRect *bg;
 		
@@ -958,7 +958,7 @@ class PropList : public UIElement {
 		UIScrollContainer *scrollContainer;		
 	protected:
 	
-		Entity *propContents;
+		UIElement *propContents;
 	
 		std::vector<PropSheet*> props;	
 		UIRect *bg;

+ 3 - 3
IDE/Contents/Include/ToolWindows.h

@@ -81,7 +81,7 @@ class YesNoPopup : public UIWindow {
 	
 		UILabel *captionLabel;
 	
-		Entity *buttonAnchor;
+		UIElement *buttonAnchor;
 		UIButton *cancelButton;
 		UIButton *okButton;	
 };
@@ -101,7 +101,7 @@ class YesNoCancelPopup : public UIWindow {
 	
 		UILabel *captionLabel;
 	
-		Entity *buttonAnchor;
+		UIElement *buttonAnchor;
 		UIButton *cancelButton;
 		UIButton *noButton;		
 		UIButton *okButton;
@@ -152,7 +152,7 @@ class AssetImporterWindow : public UIWindow {
         UICheckBox *overrideMaterial;
         UITextInput *overrideMaterialInput;
     
-		Entity *filesAnchor;
+		UIElement *filesAnchor;
 		UIScrollContainer *filesScroller;
 
 		UILabel *filesToImportLabel;

+ 3 - 3
IDE/Contents/Source/NewFileWindow.cpp

@@ -67,18 +67,18 @@ NewFileWindow::NewFileWindow() : UIWindow(L"Create New File", 580, 280) {
 	label2->setPosition(padding+270, templateContainer->getPosition().y-5);			
 	
 	fileNameInput = new UITextInput(false, 550-padding-210-padding-padding, 12);	
-	addChild(fileNameInput);
+	addFocusChild(fileNameInput);
 	fileNameInput->setPosition(label2->getPosition().x, label2->getPosition().y+30);
 	
 	
 	cancelButton = new UIButton(L"Cancel", 100);
 	cancelButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	addChild(cancelButton);
+	addFocusChild(cancelButton);
 	cancelButton->setPosition(600-100-padding-100-10, 265);
 			
 	okButton = new UIButton(L"Create File", 100);
 	okButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	addChild(okButton);
+	addFocusChild(okButton);
 	okButton->setPosition(600-100-padding, 265);	
 }
 

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

@@ -43,7 +43,7 @@ NewProjectWindow::NewProjectWindow() : UIWindow(L"Create New Project", 480, 280)
 	templateContainer->getRootNode()->setUserData(data);			
 	
 	
-	addChild(templateContainer);		
+	addChild(templateContainer);
 	templateContainer->setPosition(padding,topPadding+padding);	
 	templateContainer->getRootNode()->toggleCollapsed();
 	
@@ -70,7 +70,7 @@ NewProjectWindow::NewProjectWindow() : UIWindow(L"Create New Project", 480, 280)
 	label2->setPosition(padding+220, templateContainer->getPosition().y-2);		
 
 	projectNameInput = new UITextInput(false, 500-padding-210-padding-padding, 12);	
-	addChild(projectNameInput);
+	addFocusChild(projectNameInput);
 	projectNameInput->setPosition(label2->getPosition().x-6, label2->getPosition().y + 25);
 	
 	UILabel *label3 = new UILabel(L"PROJECT LOCATION", 18, "section", Label::ANTIALIAS_FULL);
@@ -79,25 +79,25 @@ NewProjectWindow::NewProjectWindow() : UIWindow(L"Create New Project", 480, 280)
 	label3->setPosition(padding+220, templateContainer->getPosition().y+65);		
 	
 	projectLocationInput = new UITextInput(false, 500-padding-210-padding-padding, 12);	
-	addChild(projectLocationInput);
+	addFocusChild(projectLocationInput);
 	projectLocationInput->setPosition(label3->getPosition().x-6, label3->getPosition().y+25);
 
 	
 	locationSelectButton = new UIButton(L"Choose...", 100);
 	locationSelectButton->addEventListener(this, UIEvent::CLICK_EVENT);	
-	addChild(locationSelectButton);
+	addFocusChild(locationSelectButton);
 	locationSelectButton->setPosition(500-103-padding, projectLocationInput->getPosition().y+projectLocationInput->getHeight()+10);
 	
 	
 	cancelButton = new UIButton(L"Cancel", 100);
 	cancelButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	addChild(cancelButton);
+	addFocusChild(cancelButton);
 	cancelButton->setPosition(500-100-padding-100-10, 265);
 		
 	
 	okButton = new UIButton(L"Create Project", 100);
 	okButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	addChild(okButton);
+	addFocusChild(okButton);
 	okButton->setPosition(500-100-padding, 265);
 }
 

+ 1 - 1
IDE/Contents/Source/PolycodeFontEditor.cpp

@@ -39,7 +39,7 @@ bool PolycodeFontEditor::openFile(OSFileEntry filePath) {
 	
 	CoreServices::getInstance()->getFontManager()->registerFont(filePath.fullPath, filePath.fullPath);
 		
-	anchor = new Entity();
+	anchor = new UIElement();
 	addChild(anchor);
 	anchor->snapToPixels = true;
 	

+ 1 - 1
IDE/Contents/Source/PolycodeProject.cpp

@@ -125,7 +125,7 @@ bool PolycodeProject::loadProjectFromFile() {
 			if(!color) color = configFile.root.addChild("backgroundColor");			
 			color->addChild("red", 0.0);
 			color->addChild("green", 0.0);
-			color->addChild("blue", 0.0);						
+			color->addChild("blue", 0.0);
 		}
 	}
 

+ 33 - 33
IDE/Contents/Source/PolycodeProjectEditor.cpp

@@ -46,19 +46,19 @@ ProjectFontEntry::ProjectFontEntry(String fontPath, String fontName) : UIElement
 	removeButton = new UIImageButton("main/remove_icon.png", 1.0, 12, 12);
 	removeButton->setPosition(0, 5);
 	removeButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	addChild(removeButton);
+	addFocusChild(removeButton);
 
 	fontNameInput = new UITextInput(false, 100, 13);
 	fontNameInput->setText(fontName);
 	fontNameInput->setPosition(20, 0);
 	fontNameInput->addEventListener(this, UIEvent::CHANGE_EVENT);
-	addChild(fontNameInput);
+	addFocusChild(fontNameInput);
 	
 	OSFileEntry entry = OSFileEntry(fontPath, OSFileEntry::TYPE_FILE);
 	
 	fontFileLabel = new UILabel(entry.name, 12);
 	fontFileLabel->color.a = 1.0;
-	addChild(fontFileLabel);
+	addFocusChild(fontFileLabel);
 	fontFileLabel->setPosition(140, 3);
 	
 	CoreServices::getInstance()->getFontManager()->registerFont(fontName, fontPath);
@@ -97,26 +97,26 @@ PolycodeProjectEditor::PolycodeProjectEditor(PolycodeProjectManager *projectMana
 		
 
 	headerBg = new UIRect(10,10);
-	addChild(headerBg);
+	addFocusChild(headerBg);
 	headerBg->setAnchorPoint(-1.0, -1.0, 0.0);
 	headerBg->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiHeaderBgColor"));
 	
 	UILabel *label = new UILabel("PROJECT SETTINGS", 18, "section", Label::ANTIALIAS_FULL);
 	label->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiHeaderFontColor"));
 	
-	addChild(label);
+	addFocusChild(label);
 	label->setPosition(10, 3);
 
 	moduleSettingsWindow = new UIElement();
 	moduleSettingsWindow->setPosition(350,10);
-	addChild(moduleSettingsWindow);
+	addFocusChild(moduleSettingsWindow);
 	
 	
 	Number lastYPos = 40;
 
 	label = new UILabel("PROJECT MODULES", 18, "section", Label::ANTIALIAS_FULL);
 	label->color.setColorHexFromString(conf->getStringValue("Polycode", "uiSectionFontColor"));
-	moduleSettingsWindow->addChild(label);
+	moduleSettingsWindow->addFocusChild(label);
 	label->setPosition(0, lastYPos);
 
 	lastYPos += 40;
@@ -130,7 +130,7 @@ PolycodeProjectEditor::PolycodeProjectEditor(PolycodeProjectManager *projectMana
 			UICheckBox *moduleCheckBox = new UICheckBox(entry.name, false);
 			moduleCheckBox->setPosition(0, lastYPos);
 			lastYPos += moduleCheckBox->getHeight() + 5;
-			moduleSettingsWindow->addChild(moduleCheckBox);
+			moduleSettingsWindow->addFocusChild(moduleCheckBox);
 			moduleCheckboxes.push_back(moduleCheckBox);
 		}
 	}
@@ -139,49 +139,49 @@ PolycodeProjectEditor::PolycodeProjectEditor(PolycodeProjectManager *projectMana
 
 	label = new UILabel("PROJECT FONTS", 18, "section", Label::ANTIALIAS_FULL);
 	label->color.setColorHexFromString(conf->getStringValue("Polycode", "uiSectionFontColor"));
-	moduleSettingsWindow->addChild(label);
+	moduleSettingsWindow->addFocusChild(label);
 	label->setPosition(0, lastYPos);
 	
 	lastYPos += 30;
 	
 	fontEntryBase = new UIElement();
-	moduleSettingsWindow->addChild(fontEntryBase);	
+	moduleSettingsWindow->addFocusChild(fontEntryBase);	
 	fontEntryBase->setPosition(0, lastYPos);
 			
 	addFontButton = new UIButton("Add Font", 100);
-	fontEntryBase->addChild(addFontButton);
+	fontEntryBase->addFocusChild(addFontButton);
 	addFontButton->addEventListener(this, UIEvent::CLICK_EVENT);
 
 	mainSettingsWindow = new UIElement();
 	mainSettingsWindow->setPosition(0,10);
-	addChild(mainSettingsWindow);
+	addFocusChild(mainSettingsWindow);
 	
 	UILabel *label2 = new UILabel(L"DEFAULT VIDEO OPTIONS", 18, "section", Label::ANTIALIAS_FULL);	
 	label2->color.setColorHexFromString(conf->getStringValue("Polycode", "uiSectionFontColor"));
-	mainSettingsWindow->addChild(label2);
+	mainSettingsWindow->addFocusChild(label2);
 	label2->setPosition(padding, 40);		
 
 		
 	label2 = new UILabel(L"Width", fontSize, fontName, Label::ANTIALIAS_FULL);
-	mainSettingsWindow->addChild(label2);
+	mainSettingsWindow->addFocusChild(label2);
 	label2->setPosition(padding + 6, 80);		
 	
 	defaultWidthInput = new UITextInput(false, 60, 12);	
-	mainSettingsWindow->addChild(defaultWidthInput);
+	mainSettingsWindow->addFocusChild(defaultWidthInput);
 	defaultWidthInput->setPosition(label2->getPosition().x-6, label2->getPosition().y+18);
 	defaultWidthInput->setNumberOnly(true);
 
 	label2 = new UILabel(L"Height", fontSize, fontName, Label::ANTIALIAS_FULL);
-	mainSettingsWindow->addChild(label2);
+	mainSettingsWindow->addFocusChild(label2);
 	label2->setPosition(padding + 80 + 6, 80);		
 	
 	defaultHeightInput = new UITextInput(false, 60, 12);	
-	mainSettingsWindow->addChild(defaultHeightInput);
+	mainSettingsWindow->addFocusChild(defaultHeightInput);
 	defaultHeightInput->setPosition(label2->getPosition().x-6, label2->getPosition().y+18);
 	defaultHeightInput->setNumberOnly(true);
 	
 	label2 = new UILabel(L"Anti-aliasing", fontSize, fontName, Label::ANTIALIAS_FULL);
-	mainSettingsWindow->addChild(label2);
+	mainSettingsWindow->addFocusChild(label2);
 	label2->setPosition(padding + 160 + 6, 80);		
 	
 	aaLevelComboBox = new UIComboBox(globalMenu, 120);		
@@ -192,7 +192,7 @@ PolycodeProjectEditor::PolycodeProjectEditor(PolycodeProjectManager *projectMana
 	aaLevelComboBox->setPosition(label2->getPosition().x-6, label2->getPosition().y+18);
 
 	label2 = new UILabel(L"Texture filtering mode:", fontSize, fontName, Label::ANTIALIAS_FULL);
-	mainSettingsWindow->addChild(label2);
+	mainSettingsWindow->addFocusChild(label2);
 	label2->setPosition(padding + 6, defaultHeightInput->getPosition().y+30);		
 	
 	texFilteringComboBox = new UIComboBox(globalMenu, 280);		
@@ -202,7 +202,7 @@ PolycodeProjectEditor::PolycodeProjectEditor(PolycodeProjectManager *projectMana
 	
 
 	label2 = new UILabel(L"Anisotropic filtering:", fontSize, fontName, Label::ANTIALIAS_FULL);	
-	mainSettingsWindow->addChild(label2);
+	mainSettingsWindow->addFocusChild(label2);
 	label2->setPosition(padding + 6, texFilteringComboBox->getPosition().y+30);		
 	
 	afLevelComboBox = new UIComboBox(globalMenu, 280);		
@@ -215,45 +215,45 @@ PolycodeProjectEditor::PolycodeProjectEditor(PolycodeProjectManager *projectMana
 	afLevelComboBox->setPosition(label2->getPosition().x-6, label2->getPosition().y+18);
 
 	label2 = new UILabel(L"Framerate", fontSize, fontName, Label::ANTIALIAS_FULL);
-	mainSettingsWindow->addChild(label2);
+	mainSettingsWindow->addFocusChild(label2);
 	label2->setPosition(padding + 6, afLevelComboBox->getPosition().y+30);		
 	
 	framerateInput = new UITextInput(false, 60, 12);	
-	mainSettingsWindow->addChild(framerateInput);
+	mainSettingsWindow->addFocusChild(framerateInput);
 	framerateInput->setPosition(label2->getPosition().x-6, label2->getPosition().y+18);
 	framerateInput->setNumberOnly(true);
 
 	vSyncCheckBox = new UICheckBox("V-Sync", false);
 	vSyncCheckBox->setPosition(label2->getPosition().x + 80, label2->getPosition().y+18);
-	mainSettingsWindow->addChild(vSyncCheckBox);
+	mainSettingsWindow->addFocusChild(vSyncCheckBox);
 	
 	label2 = new UILabel(L"STARTUP OPTIONS", 18, "section", Label::ANTIALIAS_FULL);	
 	label2->color.setColorHexFromString(conf->getStringValue("Polycode", "uiSectionFontColor"));
-	mainSettingsWindow->addChild(label2);
+	mainSettingsWindow->addFocusChild(label2);
 	label2->setPosition(padding, vSyncCheckBox->getPosition().y+vSyncCheckBox->getHeight()+20);		
 	
 	
 	label2 = new UILabel(L"Entry point file", fontSize, fontName, Label::ANTIALIAS_FULL);
-	mainSettingsWindow->addChild(label2);
+	mainSettingsWindow->addFocusChild(label2);
 	label2->setPosition(padding + 6, vSyncCheckBox->getPosition().y+80);		
 	
 	entryPointInput = new UITextInput(false, 200, 12);	
-	mainSettingsWindow->addChild(entryPointInput);
+	mainSettingsWindow->addFocusChild(entryPointInput);
 	entryPointInput->setPosition(label2->getPosition().x - 6, label2->getPosition().y+18);
 
 
-	mainSettingsWindow->addChild(afLevelComboBox);			
-	mainSettingsWindow->addChild(aaLevelComboBox);		
-	mainSettingsWindow->addChild(texFilteringComboBox);	
+	mainSettingsWindow->addFocusChild(afLevelComboBox);			
+	mainSettingsWindow->addFocusChild(aaLevelComboBox);		
+	mainSettingsWindow->addFocusChild(texFilteringComboBox);	
 
 	label2 = new UILabel(L"Background color:", fontSize, fontName, Label::ANTIALIAS_FULL);
-	mainSettingsWindow->addChild(label2);
+	mainSettingsWindow->addFocusChild(label2);
 	label2->setPosition(padding, entryPointInput->getPosition().y+entryPointInput->getHeight()+10);		
 
 
 	bgColorBox = new UIColorBox(globalColorPicker, Color(1.0, 0.5, 0.0, 0.9), 30,30);
 	bgColorBox->setPosition(label2->getPosition().x, label2->getPosition().y+18);
-	mainSettingsWindow->addChild(bgColorBox);
+	mainSettingsWindow->addFocusChild(bgColorBox);
 	
 	vSyncCheckBox->addEventListener(this, UIEvent::CHANGE_EVENT);
 	defaultWidthInput->addEventListener(this, UIEvent::CHANGE_EVENT);
@@ -315,7 +315,7 @@ void PolycodeProjectEditor::handleEvent(Event *event) {
 		if(!hasFont) {
 			ProjectFontEntry *newEntry = new ProjectFontEntry(newFontPath, "font_name");
 			newEntry->addEventListener(this, Event::CHANGE_EVENT);
-			fontEntryBase->addChild(newEntry);
+			fontEntryBase->addFocusChild(newEntry);
 			fontEntries.push_back(newEntry);
 			refreshFontEntries();
 		}
@@ -371,7 +371,7 @@ bool PolycodeProjectEditor::openFile(OSFileEntry filePath) {
 
 		ProjectFontEntry *newEntry = new ProjectFontEntry(fontData.fontPath, fontData.fontName);
 		newEntry->addEventListener(this, Event::CHANGE_EVENT);
-		fontEntryBase->addChild(newEntry);
+		fontEntryBase->addFocusChild(newEntry);
 		fontEntries.push_back(newEntry);
 		
 	}

+ 71 - 71
IDE/Contents/Source/PolycodeProps.cpp

@@ -121,7 +121,7 @@ PropList::PropList(String caption) : UIElement() {
 	bg->setAnchorPoint(-1.0, -1.0, 0.0);
 	bg->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiBgColor"));
 	
-	addChild(bg);
+	addFocusChild(bg);
 	bg->blockMouseInput = true;
 	bg->processInputEvents = true;
 	
@@ -131,19 +131,19 @@ PropList::PropList(String caption) : UIElement() {
 	bg2->setAnchorPoint(-1.0, -1.0, 0.0);
 	bg2->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiHeaderBgColor"));
 	
-	addChild(bg2);
+	addFocusChild(bg2);
 
 	UILabel *label = new UILabel(caption, 18, "section", Label::ANTIALIAS_FULL);
 	label->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiHeaderFontColor"));
-	addChild(label);
+	addFocusChild(label);
 	label->setPosition(10, 3);
 
-	propContents = new Entity();
+	propContents = new UIElement();
 	propContents->processInputEvents = true;
 		
 	scrollContainer = new UIScrollContainer(propContents, false, true, 100, 100);
 	scrollContainer->setPosition(0, 30);
-	addChild(scrollContainer);
+	addFocusChild(scrollContainer);
     
     ownsChildren = true;
 }
@@ -200,7 +200,7 @@ void PropList::handleEvent(Event *event) {
 }
 
 void PropList::addPropSheet(PropSheet *sheet) {
-	propContents->addChild(sheet);
+	propContents->addFocusChild(sheet);
 	props.push_back(sheet);
 	Resize(getWidth(), getHeight());
 	sheet->addEventListener(this, Event::COMPLETE_EVENT);
@@ -214,27 +214,27 @@ PropSheet::PropSheet(String caption, String type) : UIElement() {
 	customUndoHandler = false;
 	
 	bg = new UIRect(30,30);
-	addChild(bg);
+	addFocusChild(bg);
 	bg->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiSmallHeaderBgColor"));
 	bg->setAnchorPoint(-1.0, -1.0, 0.0);
 	
 	UILabel *label = new UILabel(caption, 18, "section", Label::ANTIALIAS_FULL);
 	label->color.a = 1.0;
-	addChild(label);
+	addFocusChild(label);
 	label->setPosition(25, 3);	
 	
-	contents = new Entity();
+	contents = new UIElement();
 	contents->processInputEvents = true;
-	addChild(contents);
+	addFocusChild(contents);
 	contents->setPosition(20,35);
 	
 	collapseButton = new UIImageButton("main/collapse.png", 1.0, 12, 12);
-	addChild(collapseButton);
+	addFocusChild(collapseButton);
 	collapseButton->addEventListener(this, UIEvent::CLICK_EVENT);
 	collapseButton->setPosition(5, 9);
 
 	expandButton = new UIImageButton("main/expand.png", 1.0, 12, 12);
-	addChild(expandButton);
+	addFocusChild(expandButton);
 	expandButton->addEventListener(this, UIEvent::CLICK_EVENT);	
 	expandButton->setPosition(5, 9);
 	expandButton->enabled = false;
@@ -317,7 +317,7 @@ void PropSheet::layoutProps() {
 }
 
 void PropSheet::addProp(PropProp *prop) {
-	contents->addChild(prop);
+	contents->addFocusChild(prop);
 	props.push_back(prop);
 	prop->addEventListener(this, Event::CHANGE_EVENT);
 	prop->addEventListener(this, PropEvent::EVENT_PROP_CHANGE);	
@@ -339,11 +339,11 @@ PropProp::PropProp(String caption, String type) : UIElement() {
 	propType = type;
 	label = new UILabel(caption, 11);
 	label->setPosition(0, 5);
-	addChild(label);
+	addFocusChild(label);
 	
-	propContents = new Entity();
+	propContents = new UIElement();
 	propContents->processInputEvents = true;
-	addChild(propContents);
+	addFocusChild(propContents);
 	propContents->setPosition(100, 0);
 	
 	setHeight(20);
@@ -355,7 +355,7 @@ PropProp::~PropProp() {
 
 ButtonProp::ButtonProp(const String &caption) : PropProp("", "ButtonProp") {
     button = new UIButton(caption, 100);
-    addChild(button);
+    addFocusChild(button);
     setHeight(25);
 }
 
@@ -380,38 +380,38 @@ Vector3Prop::Vector3Prop(String caption) : PropProp(caption, "Vector3") {
     
 	labelX = new UILabel("X:", 11);
 	labelX->color.a = 1.0;
-	propContents->addChild(labelX);
+	propContents->addFocusChild(labelX);
 	labelX->setPosition(-20, 5);
     
 	labelY = new UILabel("Y:", 11);
 	labelY->color.a = 1.0;
-	propContents->addChild(labelY);
+	propContents->addFocusChild(labelY);
 	labelY->setPosition(-20, 25);
 
     labelZ = new UILabel("Z:", 11);
 	labelZ->color.a = 1.0;
-	propContents->addChild(labelZ);
+	propContents->addFocusChild(labelZ);
 	labelZ->setPosition(-20, 45);
     
 	xInput = new UITextInput(false, 50, 12);
 	xInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 	xInput->setText("0");
 	xInput->setNumberOnly(true);
-	propContents->addChild(xInput);
+	propContents->addFocusChild(xInput);
 	xInput->setPosition(0, 0);
 
    	yInput = new UITextInput(false, 50, 12);
 	yInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 	yInput->setText("0");
 	yInput->setNumberOnly(true);
-	propContents->addChild(yInput);
+	propContents->addFocusChild(yInput);
 	yInput->setPosition(0, 20);
 
     zInput = new UITextInput(false, 50, 12);
 	zInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 	zInput->setText("0");
 	zInput->setNumberOnly(true);
-	propContents->addChild(zInput);
+	propContents->addFocusChild(zInput);
 	zInput->setPosition(0, 40);
 
 	setHeight(65);
@@ -467,12 +467,12 @@ Vector2Prop::Vector2Prop(String caption) : PropProp(caption, "Vector2") {
 
 	labelX = new UILabel("X:", 11);
 	labelX->color.a = 1.0;
-	propContents->addChild(labelX);
+	propContents->addFocusChild(labelX);
 	labelX->setPosition(-20, 6);	
 
 	labelY = new UILabel("Y:", 11);
 	labelY->color.a = 1.0;
-	propContents->addChild(labelY);
+	propContents->addFocusChild(labelY);
 	labelY->setPosition(60, 6);	
 	
 	positionX = NULL;
@@ -482,14 +482,14 @@ Vector2Prop::Vector2Prop(String caption) : PropProp(caption, "Vector2") {
 	positionX->addEventListener(this, UIEvent::CHANGE_EVENT);
 	positionX->setText("0");
 	positionX->setNumberOnly(true);
-	propContents->addChild(positionX);
+	propContents->addFocusChild(positionX);
 	positionX->setPosition(0, 0);
 
 	positionY = new UITextInput(false, 50, 12);
 	positionY->setText("0");
 	positionY->addEventListener(this, UIEvent::CHANGE_EVENT);	
 	positionY->setNumberOnly(true);
-	propContents->addChild(positionY);
+	propContents->addFocusChild(positionY);
 	positionY->setPosition(80, 0);
 
 	setHeight(25);
@@ -548,12 +548,12 @@ Vector2Prop::~Vector2Prop() {
 RemovableStringProp::RemovableStringProp(const String &caption) : PropProp("", "RemovableStringProp") {
     
     label = new UILabel(caption, 12);
-    addChild(label);
+    addFocusChild(label);
     label->setPositionX(30);
     
    	removeButton = new UIImageButton("main/remove_icon.png", 1.0, 12, 12);
 	removeButton->addEventListener(this, UIEvent::CLICK_EVENT);
-    addChild(removeButton);
+    addFocusChild(removeButton);
 	removeButton->setPosition(0, 2);
 
 	setHeight(25);
@@ -579,7 +579,7 @@ LayerProp::LayerProp(SceneEntityInstance *instance, SceneEntityInstanceLayer *la
     bgRect = new UIRect(1.0, 1.0);
     bgRect->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiHeaderBgColor"));
 
-    propContents->addChild(bgRect);
+    propContents->addFocusChild(bgRect);
     
     this->layer = layer;
     this->instance = instance;
@@ -587,32 +587,32 @@ LayerProp::LayerProp(SceneEntityInstance *instance, SceneEntityInstanceLayer *la
     layerID = layer->layerID;
     
     removeLayerButton = new UIImageButton("main/remove_icon.png", 1.0, 12, 12);
-    propContents->addChild(removeLayerButton);
+    propContents->addFocusChild(removeLayerButton);
     removeLayerButton->setPosition(-95, 5.0);
     removeLayerButton->addEventListener(this, UIEvent::CLICK_EVENT);
     
     hideLayerButton = new UIImageButton("entityEditor/visible_button.png", 1.0, 24, 24);
-    propContents->addChild(hideLayerButton);
+    propContents->addFocusChild(hideLayerButton);
     hideLayerButton->setPosition(-95, 0.0);
     hideLayerButton->addEventListener(this, UIEvent::CLICK_EVENT);
 
     
     showLayerButton = new UIImageButton("entityEditor/invisible_button.png", 1.0, 24, 24);
-    propContents->addChild(showLayerButton);
+    propContents->addFocusChild(showLayerButton);
     showLayerButton->setPosition(-95, 0.0);
     showLayerButton->addEventListener(this, UIEvent::CLICK_EVENT);
     showLayerButton->visible = false;
     showLayerButton->enabled = false;
     
     moreButton = new UIImageButton("entityEditor/button_more.png", 1.0, 24, 24);
-    propContents->addChild(moreButton);
+    propContents->addFocusChild(moreButton);
     moreButton->setPosition(-70, 0.0);
     moreButton->addEventListener(this, UIEvent::CLICK_EVENT);
     
     
     layerName = new UILabel(layer->name, 12);
     layerName->setColor(1.0, 1.0, 1.0, 1.0);
-    propContents->addChild(layerName);
+    propContents->addFocusChild(layerName);
     layerName->setPosition(-40, 5.0);
     
     if(layerID == 0) {
@@ -701,18 +701,18 @@ CustomProp::CustomProp(String key, String value) : PropProp("", "Custom") {
 	keyEntry = new UITextInput(false, 120, 12);
 	keyEntry->setText(key);
 	keyEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
-	propContents->addChild(keyEntry);
+	propContents->addFocusChild(keyEntry);
 	keyEntry->setPosition(-90, 0);
 
 	valueEntry = new UITextInput(false, 120, 12);
 	valueEntry->setText(value);	
 	valueEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
-	propContents->addChild(valueEntry);
+	propContents->addFocusChild(valueEntry);
 	valueEntry->setPosition(45, 0);
 	
 	removeButton = new UIImageButton("main/remove_icon.png", 1.0, 12, 12);
 	removeButton->addEventListener(this, UIEvent::CLICK_EVENT);	
-	propContents->addChild(removeButton);
+	propContents->addFocusChild(removeButton);
 	removeButton->setPosition(-110, 6);
 	
 	setHeight(25);
@@ -763,7 +763,7 @@ StringProp::StringProp(String caption) : PropProp(caption, "String") {
 	stringEntry = new UITextInput(false, 150, 12);
 	stringEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
 	stringEntry->setText("");
-	propContents->addChild(stringEntry);
+	propContents->addFocusChild(stringEntry);
 	stringEntry->setPosition(0, 0);
 	setHeight(25);
 }
@@ -813,10 +813,10 @@ SliderProp::SliderProp(String caption, Number min, Number max) : PropProp(captio
 	slider->addEventListener(this, UIEvent::CHANGE_EVENT);
 	slider->setPosition(0, 8);
     slider->setContinuous(false);
-	propContents->addChild(slider);
+	propContents->addFocusChild(slider);
 	
 	valueLabel = new UILabel("0.0", 10);
-	propContents->addChild(valueLabel);
+	propContents->addFocusChild(valueLabel);
 	valueLabel->setPosition(120, 5);
 	valueLabel->color.a = 1.0;
 	setHeight(25);
@@ -872,7 +872,7 @@ NumberProp::NumberProp(String caption) : PropProp(caption, "Number") {
 	numberEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
 	numberEntry->setText("0");
 	numberEntry->setNumberOnly(true);
-	propContents->addChild(numberEntry);
+	propContents->addFocusChild(numberEntry);
 	numberEntry->setPosition(0, 2);
 
 	setHeight(25);
@@ -923,7 +923,7 @@ ColorProp::ColorProp(String caption) : PropProp(caption, "Color") {
 	colorEntry = new UIColorBox(globalColorPicker, Color(), 45, 25);
 	colorEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
 	colorEntry->setPosition(-2, 0);
-	propContents->addChild(colorEntry);
+	propContents->addFocusChild(colorEntry);
 	setHeight(25);
 
 }
@@ -968,7 +968,7 @@ ColorProp::~ColorProp() {
 ComboProp::ComboProp(String caption) : PropProp(caption, "Combo") {
 	comboEntry = new UIComboBox(globalMenu, 150);
 	comboEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
-	propContents->addChild(comboEntry);
+	propContents->addFocusChild(comboEntry);
 	comboEntry->setPosition(-3, 0);
 	setHeight(25);
 }
@@ -1015,7 +1015,7 @@ BoolProp::BoolProp(String caption) : PropProp(caption, "Bool") {
 	checkEntry = new UICheckBox("", false);
 	checkEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
 	checkEntry->setPosition(0, 4);
-	propContents->addChild(checkEntry);
+	propContents->addFocusChild(checkEntry);
 	setHeight(25);
 
 }
@@ -1056,17 +1056,17 @@ SoundProp::SoundProp(String caption) : PropProp(caption, "Sound"){
 
 	soundFile = new UILabel("", 11);
 	soundFile->setPosition(0, 5);
-	propContents->addChild(soundFile);	
+	propContents->addFocusChild(soundFile);	
 	soundFile->color.a = 1.0;
 
 	playButton = new UIButton("Play", 50);
-	propContents->addChild(playButton);
+	propContents->addFocusChild(playButton);
 	playButton->setPosition(0, 25);
 	playButton->addEventListener(this, UIEvent::CLICK_EVENT);
 
 
 	changeButton = new UIButton("Change", 80);
-	propContents->addChild(changeButton);
+	propContents->addFocusChild(changeButton);
 	changeButton->setPosition(60, 25);
 	changeButton->addEventListener(this, UIEvent::CLICK_EVENT);
 	setHeight(70);
@@ -1139,7 +1139,7 @@ BezierRGBACurveProp::BezierRGBACurveProp(String caption) : PropProp(caption, "Be
 
 
 	changeButton = new UIButton("Edit", 120);
-	propContents->addChild(changeButton);
+	propContents->addFocusChild(changeButton);
 	changeButton->setPosition(0, 0);
 	changeButton->addEventListener(this, UIEvent::CLICK_EVENT);
 
@@ -1173,7 +1173,7 @@ BezierCurveProp::BezierCurveProp(String caption, String curveName) : PropProp(ca
 	this->curveName = curveName;
 
 	changeButton = new UIButton("Edit", 120);
-	propContents->addChild(changeButton);
+	propContents->addFocusChild(changeButton);
 	changeButton->setPosition(0, 0);
 	changeButton->addEventListener(this, UIEvent::CLICK_EVENT);
 
@@ -1202,15 +1202,15 @@ MaterialProp::MaterialProp(const String &caption) : PropProp(caption, "Material"
 	previewShape = new UIRect(48, 48);
 	previewShape->setAnchorPoint(-1.0, -1.0, 0.0);
 	previewShape->setPosition(2, 1);
-	propContents->addChild(previewShape);
+	propContents->addFocusChild(previewShape);
     
 	changeButton = new UIButton("Change", 80);
-	propContents->addChild(changeButton);
+	propContents->addFocusChild(changeButton);
 	changeButton->setPosition(60, 5);
 	changeButton->addEventListener(this, UIEvent::CLICK_EVENT);
 	
 	materialLabel = new UILabel("", 12, "sans");
-	propContents->addChild(materialLabel);
+	propContents->addFocusChild(materialLabel);
 	materialLabel->setPosition(-100, 32);
 	materialLabel->color.a = 1.0;
     
@@ -1318,15 +1318,15 @@ TextureProp::TextureProp(String caption) : PropProp(caption, "Texture"){
 	previewShape = new UIRect(48, 48);
 	previewShape->setAnchorPoint(-1.0, -1.0, 0.0);
 	previewShape->setPosition(2, 1);
-	propContents->addChild(previewShape);
+	propContents->addFocusChild(previewShape);
 
 	changeButton = new UIButton("Change", 80);
-	propContents->addChild(changeButton);
+	propContents->addFocusChild(changeButton);
 	changeButton->setPosition(60, 5);
 	changeButton->addEventListener(this, UIEvent::CLICK_EVENT);
 	
 	textureLabel = new UILabel("", 12, "sans");
-	propContents->addChild(textureLabel);
+	propContents->addFocusChild(textureLabel);
 	textureLabel->setPosition(-100, 32);
 	textureLabel->color.a = 1.0;
 		
@@ -1398,13 +1398,13 @@ SceneSpriteProp::SceneSpriteProp(String caption) : PropProp(caption, "SceneSprit
 	previewSprite = NULL;
     
 	changeButton = new UIButton("Change", 80);
-	propContents->addChild(changeButton);
+	propContents->addFocusChild(changeButton);
 	changeButton->setPosition(60, 5);
 	changeButton->addEventListener(this, UIEvent::CLICK_EVENT);
 	setHeight(55);
     
 	spriteName = new UILabel("", 12, "sans");
-	propContents->addChild(spriteName);
+	propContents->addFocusChild(spriteName);
 	spriteName->setPosition(-100, 32);
 	spriteName->color.a = 1.0;
     
@@ -1511,7 +1511,7 @@ SceneEntityInstanceProp::SceneEntityInstanceProp(String caption) : PropProp(capt
 	propContents->addChild(previewInstance);
 
 	changeButton = new UIButton("Change", 80);
-	propContents->addChild(changeButton);
+	propContents->addFocusChild(changeButton);
 	changeButton->setPosition(60, 5);
 	changeButton->addEventListener(this, UIEvent::CLICK_EVENT);
 	setHeight(50);
@@ -1576,12 +1576,12 @@ ShaderPassProp::ShaderPassProp(Material *material, int shaderIndex) : PropProp("
 	
 	removeButton = new UIImageButton("main/remove_icon.png", 1.0, 12, 12);
 	removeButton->addEventListener(this, UIEvent::CLICK_EVENT);	
-	propContents->addChild(removeButton);
+	propContents->addFocusChild(removeButton);
 	removeButton->setPosition(-110, 6);
 	
 	shaderComboBox = new UIComboBox(globalMenu, 100);
 	shaderComboBox->addEventListener(this, UIEvent::CHANGE_EVENT);
-	propContents->addChild(shaderComboBox);
+	propContents->addFocusChild(shaderComboBox);
 	
 	int index = 0;
 	MaterialManager *materialManager = CoreServices::getInstance()->getMaterialManager();
@@ -1598,7 +1598,7 @@ ShaderPassProp::ShaderPassProp(Material *material, int shaderIndex) : PropProp("
 	
 	editButton = new UIButton("Options", 30);
 	editButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	propContents->addChild(editButton);
+	propContents->addFocusChild(editButton);
 	setHeight(25);
 }
 
@@ -1641,7 +1641,7 @@ TargetBindingProp::TargetBindingProp(Shader *shader, Material *material, ShaderB
 		
 	removeButton = new UIImageButton("main/remove_icon.png", 1.0, 12, 12);
 	removeButton->addEventListener(this, UIEvent::CLICK_EVENT);	
-	propContents->addChild(removeButton);
+	propContents->addFocusChild(removeButton);
 	removeButton->setPosition(-110, 6);
 
 	typeComboBox = new UIComboBox(globalMenu, 100);
@@ -1651,7 +1651,7 @@ TargetBindingProp::TargetBindingProp(Shader *shader, Material *material, ShaderB
 	typeComboBox->addComboItem("DEPTH");		
 	typeComboBox->setSelectedIndex(targetBinding->mode);
 	typeComboBox->addEventListener(this, UIEvent::CHANGE_EVENT);
-	propContents->addChild(typeComboBox);
+	propContents->addFocusChild(typeComboBox);
 
 	targetComboBox = new UIComboBox(globalMenu, 100);	
 	for(int i=0; i < material->getNumShaderRenderTargets(); i++) {
@@ -1662,7 +1662,7 @@ TargetBindingProp::TargetBindingProp(Shader *shader, Material *material, ShaderB
 		}
 	}
 	targetComboBox->addEventListener(this, UIEvent::CHANGE_EVENT);
-	propContents->addChild(targetComboBox);
+	propContents->addFocusChild(targetComboBox);
 	
 	textureComboBox = new UIComboBox(globalMenu, 100);	
 	for(int i=0; i < shader->expectedTextures.size(); i++) {
@@ -1673,7 +1673,7 @@ TargetBindingProp::TargetBindingProp(Shader *shader, Material *material, ShaderB
 	}
 		
 	textureComboBox->addEventListener(this, UIEvent::CHANGE_EVENT);
-	propContents->addChild(textureComboBox);
+	propContents->addFocusChild(textureComboBox);
 	
 	setHeight(25);
 	
@@ -1774,26 +1774,26 @@ RenderTargetProp::RenderTargetProp(ShaderRenderTarget *renderTarget, Material *m
 
 	removeButton = new UIImageButton("main/remove_icon.png", 1.0, 12, 12);
 	removeButton->addEventListener(this, UIEvent::CLICK_EVENT);	
-	propContents->addChild(removeButton);
+	propContents->addFocusChild(removeButton);
 	removeButton->setPosition(-110, 6);
 	
 	nameInput = new UITextInput(false, 20, 12);
 	nameInput->addEventListener(this, UIEvent::CHANGE_EVENT);
-	propContents->addChild(nameInput);
+	propContents->addFocusChild(nameInput);
 	nameInput->setText(renderTarget->id);
 	nameInput->setCaretPosition(0);
 	
 	widthInput = new UITextInput(false, 20, 12);
 	widthInput->setNumberOnly(true);
 	widthInput->setText(String::NumberToString(renderTarget->width));
-	propContents->addChild(widthInput);
+	propContents->addFocusChild(widthInput);
 	widthInput->setCaretPosition(0);
 	widthInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 		
 	heightInput = new UITextInput(false, 20, 12);
 	heightInput->setNumberOnly(true);
 	heightInput->setText(String::NumberToString(renderTarget->height));	
-	propContents->addChild(heightInput);
+	propContents->addFocusChild(heightInput);
 	heightInput->setCaretPosition(0);
 	heightInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 			
@@ -1802,7 +1802,7 @@ RenderTargetProp::RenderTargetProp(ShaderRenderTarget *renderTarget, Material *m
 	typeComboBox->addComboItem("Norm.");
 	typeComboBox->setSelectedIndex(renderTarget->sizeMode);	
 	typeComboBox->addEventListener(this, UIEvent::CHANGE_EVENT);
-	propContents->addChild(typeComboBox);
+	propContents->addFocusChild(typeComboBox);
 	
 	setHeight(25);
 }

+ 3 - 3
IDE/Contents/Source/PolycodeTextEditor.cpp

@@ -679,15 +679,15 @@ FindBar::FindBar() : UIElement() {
 	processInputEvents = true;
 	
 	findInput = new UITextInput(false, 120, 12);
-	addChild(findInput);
+	addFocusChild(findInput);
 	findInput->setPosition(60, 4);
 
 	replaceInput = new UITextInput(false, 120, 12);
-	addChild(replaceInput);
+	addFocusChild(replaceInput);
 	replaceInput->setPosition(280, 4);
 	
 	replaceAllButton = new UIButton("Replace All", 100);
-	addChild(replaceAllButton);
+	addFocusChild(replaceAllButton);
 	replaceAllButton->setPosition(420, 3);
 
 	UIImage *functionIcon = new UIImage("main/function_icon.png", 11, 17);

+ 38 - 38
IDE/Contents/Source/ToolWindows.cpp

@@ -26,17 +26,17 @@
 TextInputPopup::TextInputPopup() : UIWindow(L"", 300, 80) {
 	
 	textInput = new UITextInput(false, 290, 12);	
-	addChild(textInput);
+	addFocusChild(textInput);
 	textInput->setPosition(padding, 35);
 		
 	cancelButton = new UIButton(L"Cancel", 100);
 	cancelButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	addChild(cancelButton);
+	addFocusChild(cancelButton);
 	cancelButton->setPosition(padding+300-100-100-10, 64);		
 	
 	okButton = new UIButton(L"OK", 100);
 	okButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	addChild(okButton);
+	addFocusChild(okButton);
 	okButton->setPosition(padding+300-100, 64);
 	
 	closeOnEscape = true;
@@ -82,12 +82,12 @@ TextInputPopup::~TextInputPopup() {
 
 MessagePopup::MessagePopup() : UIWindow("", 300, 80) {
     captionLabel = new UILabel("This is a caption", 12);
-	addChild(captionLabel);
+	addFocusChild(captionLabel);
 	captionLabel->setPosition(padding, 35);
     
 	okButton = new UIButton(L"OK", 100);
 	okButton->addEventListener(this, UIEvent::CLICK_EVENT);
-    addChild(okButton);
+    addFocusChild(okButton);
 	okButton->setPosition(120, 60);
 	
 	closeOnEscape = true;
@@ -128,21 +128,21 @@ void MessagePopup::handleEvent(Event *event) {
 YesNoPopup::YesNoPopup() : UIWindow(L"", 300, 80) {
 	
 	captionLabel = new UILabel("This is a caption", 12);	
-	addChild(captionLabel);
+	addFocusChild(captionLabel);
 	captionLabel->setPosition(padding, 35);
 		
-	buttonAnchor = new Entity();
+	buttonAnchor = new UIElement();
 	buttonAnchor->processInputEvents = true;
-	addChild(buttonAnchor);
+	addFocusChild(buttonAnchor);
 			
 	cancelButton = new UIButton(L"No", 100);
 	cancelButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	buttonAnchor->addChild(cancelButton);
+	buttonAnchor->addFocusChild(cancelButton);
 	cancelButton->setPosition(0, 60);		
 	
 	okButton = new UIButton(L"Yes", 100);
 	okButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	buttonAnchor->addChild(okButton);
+	buttonAnchor->addFocusChild(okButton);
 	okButton->setPosition(120, 60);
 	
 	closeOnEscape = true;
@@ -192,26 +192,26 @@ void YesNoCancelPopup::onGainFocus() {
 YesNoCancelPopup::YesNoCancelPopup() : UIWindow(L"", 300, 80) {
 	
 	captionLabel = new UILabel("This is a caption", 12);	
-	addChild(captionLabel);
+	addFocusChild(captionLabel);
 	captionLabel->setPosition(padding, 35);
 		
-	buttonAnchor = new Entity();
+	buttonAnchor = new UIElement();
 	buttonAnchor->processInputEvents = true;
-	addChild(buttonAnchor);
+	addFocusChild(buttonAnchor);
 	
 	noButton = new UIButton(L"No", 100);
 	noButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	buttonAnchor->addChild(noButton);
+	buttonAnchor->addFocusChild(noButton);
 	noButton->setPosition(0, 60);		
 	
 	okButton = new UIButton(L"Yes", 100);
 	okButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	buttonAnchor->addChild(okButton);
+	buttonAnchor->addFocusChild(okButton);
 	okButton->setPosition(120, 60);
 	
 	cancelButton = new UIButton(L"Cancel", 100);
 	cancelButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	buttonAnchor->addChild(cancelButton);
+	buttonAnchor->addFocusChild(cancelButton);
 	cancelButton->setPosition(240, 60);		
 
 	closeOnEscape = true;
@@ -256,93 +256,93 @@ YesNoCancelPopup::~YesNoCancelPopup() {
 
 AssetImporterWindow::AssetImporterWindow() : UIWindow("3D Asset Importer", 650, 330) {
 	filesToImportLabel = new UILabel("Files that will be imported:", 12);
-	addChild(filesToImportLabel);
+	addFocusChild(filesToImportLabel);
 	filesToImportLabel->setPosition(padding, 35);
 	
-	filesAnchor = new Entity();	
+	filesAnchor = new UIElement();	
 		
 	filesScroller = new UIScrollContainer(filesAnchor, true, true, 270, 200);
-	addChild(filesScroller);
+	addFocusChild(filesScroller);
 	filesScroller->setPosition(padding, 60);
 		
 	cancelButton = new UIButton(L"Cancel", 100);
 	cancelButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	addChild(cancelButton);
+	addFocusChild(cancelButton);
 	cancelButton->setPosition(padding+650-100-100-10-10, 315);
 	
 	okButton = new UIButton(L"OK", 100);
 	okButton->addEventListener(this, UIEvent::CLICK_EVENT);
-	addChild(okButton);
+	addFocusChild(okButton);
 	okButton->setPosition(padding+650-100-10, 315);
 	
 	closeOnEscape = true;
 
 	prefixInput = new UITextInput(false, 200, 16);
 	prefixInput->setPosition(290, 30);
-	addChild(prefixInput); 
+	addFocusChild(prefixInput); 
 	prefixInput->addEventListener(this, UIEvent::CHANGE_EVENT);
 		
 	usePrefixCheckbox = new UICheckBox("Custom filename prefix", false);
 	usePrefixCheckbox->setPosition(290, 60);
-	addChild(usePrefixCheckbox);
+	addFocusChild(usePrefixCheckbox);
 	usePrefixCheckbox->addEventListener(this, UIEvent::CHANGE_EVENT);
 	
 	addMeshesCheckbox = new UICheckBox("Add all meshes to a single mesh", false);
 	addMeshesCheckbox->setPosition(290, 90);
-	addChild(addMeshesCheckbox); 
+	addFocusChild(addMeshesCheckbox); 
 	addMeshesCheckbox->addEventListener(this, UIEvent::CHANGE_EVENT);
 	
 	generateNormalsCheckbox = new UICheckBox("Generate normals", false);
 	generateNormalsCheckbox->setPosition(290, 120);
-	addChild(generateNormalsCheckbox);
+	addFocusChild(generateNormalsCheckbox);
     
 	generateTangensCheckbox = new UICheckBox("Generate tangents", true);
 	generateTangensCheckbox->setPosition(290, 150);
-	addChild(generateTangensCheckbox);
+	addFocusChild(generateTangensCheckbox);
 
 	swapZYAxisCheckbox = new UICheckBox("Swap Z/Y axis (e.g. for Blender)", false);
 	swapZYAxisCheckbox->setPosition(290, 180);
-	addChild(swapZYAxisCheckbox);
+	addFocusChild(swapZYAxisCheckbox);
     
     exportNormals = new UICheckBox("Vertex normals", true);
 	exportNormals->setPosition(520, 30);
-	addChild(exportNormals);
+	addFocusChild(exportNormals);
     
     exportTangents = new UICheckBox("Vertex tangents", true);
 	exportTangents->setPosition(520, 60);
-	addChild(exportTangents);
+	addFocusChild(exportTangents);
     
     exportColors = new UICheckBox("Vertex colors", false);
 	exportColors->setPosition(520, 90);
-	addChild(exportColors);
+	addFocusChild(exportColors);
     
     exportBoneWeights = new UICheckBox("Bone weights", false);
 	exportBoneWeights->setPosition(520, 120);
-	addChild(exportBoneWeights);
+	addFocusChild(exportBoneWeights);
     
     exportUVs = new UICheckBox("UV coordinates", true);
 	exportUVs->setPosition(520, 150);
-	addChild(exportUVs);
+	addFocusChild(exportUVs);
     
     exportSecondaryUVs = new UICheckBox("Secondary UVs", false);
 	exportSecondaryUVs->setPosition(520, 180);
-	addChild(exportSecondaryUVs);
+	addFocusChild(exportSecondaryUVs);
 
     exportScene = new UICheckBox("Export Entity file", false);
 	exportScene->setPosition(290, 240);
-	addChild(exportScene);
+	addFocusChild(exportScene);
 
     generateMatFile = new UICheckBox("Generate material file", false);
 	generateMatFile->setPosition(450, 240);
-	addChild(generateMatFile);
+	addFocusChild(generateMatFile);
 
     overrideMaterial = new UICheckBox("Override materials:", false);
 	overrideMaterial->setPosition(290, 270);
-	addChild(overrideMaterial);
+	addFocusChild(overrideMaterial);
 
     overrideMaterialInput = new UITextInput(false, 200, 16);
 	overrideMaterialInput->setPosition(450, 265);
-	addChild(overrideMaterialInput);
+	addFocusChild(overrideMaterialInput);
     overrideMaterialInput->setText("Default");
     
 }
@@ -383,7 +383,7 @@ void AssetImporterWindow::clearFiles() {
 
 void AssetImporterWindow::addFile(String fileName) {
 	UILabel *fileLabel = new UILabel(fileName, 12);
-	filesAnchor->addChild(fileLabel);
+	filesAnchor->addFocusChild(fileLabel);
 	fileLabel->setPosition(0.0, 14 * fileLabels.size());
 
 	if(fileLabel->getWidth() > filesScroller->getContentSize().x) {

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

@@ -43,16 +43,17 @@ namespace Polycode {
 			bool hasFocus;
 			bool focusable;
 			
-			void addChild(Entity *child);
-			
 			void setDragLimits(Rectangle rect);
 			void clearDragLimits();
 			bool isDragged();
 			void startDrag(Number xOffset, Number yOffset);
 			void stopDrag();
+        
+            void handleEvent(Event *event);
 			
 			void focusChild(UIElement *child);
 			void focusNextChild();
+			void focusPreviousChild();
 			bool isFocusable();
 			void focusSelf();
 									

+ 2 - 0
Modules/Contents/UI/Source/PolyUIButton.cpp

@@ -169,4 +169,6 @@ void UIButton::handleEvent(Event *event) {
 			break;
 		}
 	}
+    
+    UIElement::handleEvent(event);    
 }

+ 1 - 0
Modules/Contents/UI/Source/PolyUICheckBox.cpp

@@ -110,4 +110,5 @@ void UICheckBox::handleEvent(Event *event) {
 			break;
 		}
 	}
+    UIElement::handleEvent(event);    
 }

+ 2 - 0
Modules/Contents/UI/Source/PolyUIComboBox.cpp

@@ -194,4 +194,6 @@ void UIComboBox::handleEvent(Event *event) {
 			break;
 		}
 	}
+    
+    UIElement::handleEvent(event);    
 }

+ 66 - 14
Modules/Contents/UI/Source/PolyUIElement.cpp

@@ -25,6 +25,8 @@
 #include "PolyCoreServices.h"
 #include "PolyTexture.h"
 #include "PolyConfig.h"
+#include "PolyCoreInput.h"
+#include "PolyInputEvent.h"
 
 using namespace Polycode;
 
@@ -308,7 +310,8 @@ UIElement::UIElement() : Entity() {
 	hasDragLimits = false;
 	dragged = false;
 	depthTest = false;
-	depthWrite = false;			
+	depthWrite = false;
+    Services()->getInput()->addEventListenerUnique(this, InputEvent::EVENT_KEYDOWN);
 }
 
 UIElement::UIElement(Number width, Number height) : Entity() {
@@ -316,20 +319,30 @@ UIElement::UIElement(Number width, Number height) : Entity() {
 	processInputEvents = true;
 	focusParent = NULL;
 	hasFocus = false;
-	hasDragLimits = false;	
+	hasDragLimits = false;
+	focusable = false;
 	dragged = false;	
 	depthTest = false;
 	depthWrite = false;		
 	setWidth(width);
 	setHeight(height);
-}
-
-void UIElement::addChild(Entity *child) {
-	UIElement* uiChild = dynamic_cast<UIElement*>(child);
-	if(uiChild) {
-		addFocusChild(uiChild);
-	}
-	Entity::addChild(child);
+    Services()->getInput()->addEventListener(this, InputEvent::EVENT_KEYDOWN);
+}
+
+void UIElement::handleEvent(Event *event) {
+    if(event->getDispatcher() == Services()->getInput() && event->getEventCode() == InputEvent::EVENT_KEYDOWN) {
+        if(hasFocus && focusParent) {
+            InputEvent *inputEvent = (InputEvent*) event;
+            if(inputEvent->key == KEY_TAB) {
+                if(Services()->getInput()->getKeyState(KEY_RSHIFT) || Services()->getInput()->getKeyState(KEY_LSHIFT)) {
+                    focusParent->focusPreviousChild();
+                } else {
+                    focusParent->focusNextChild();
+                }
+                inputEvent->cancelEvent();
+            }
+        }
+    }
 }
 
 void UIElement::setDragLimits(Rectangle rect) {
@@ -387,11 +400,45 @@ MouseEventResult UIElement::onMouseMove(const Ray &ray, int timestamp) {
 }
 
 UIElement::~UIElement() {
+    
+    Services()->getInput()->removeAllHandlersForListener(this);
+
 	if(UIElement::globalFocusedChild == this) {
 		UIElement::globalFocusedChild = NULL;
 	}
 }
 
+void UIElement::focusPreviousChild() {
+    
+    int j = 0;
+    bool hasFocusedChild = false;
+    if(UIElement::globalFocusedChild) {
+        for(int i=0; i < focusChildren.size(); i++) {
+            if(focusChildren[i] == UIElement::globalFocusedChild) {
+                j = i;
+                hasFocusedChild = true;
+            }
+        }
+    }
+    
+    if(!hasFocusedChild) {
+        return;
+    }
+    
+    for(int i=0; i < focusChildren.size(); i++) {
+        if(focusChildren[j]->isFocusable() && focusChildren[j] != UIElement::globalFocusedChild) {
+            focusChild(focusChildren[j]);
+            return;
+        }
+        
+        j--;
+        if(j == -1) {
+            j = focusChildren.size()-1;
+        }
+    }
+}
+
+
 void UIElement::focusNextChild() {
 
 	int j = 0;
@@ -405,8 +452,9 @@ void UIElement::focusNextChild() {
 		}
 	}
 
-	if(!hasFocusedChild)
+    if(!hasFocusedChild) {
 		return;
+    }
 
 	for(int i=0; i < focusChildren.size(); i++) {
 		if(focusChildren[j]->isFocusable() && focusChildren[j] != UIElement::globalFocusedChild) {
@@ -415,8 +463,9 @@ void UIElement::focusNextChild() {
 		}
 
 		j++;
-		if(j == focusChildren.size())
+        if(j == focusChildren.size()) {
 			j = 0;
+        }
 	}
 }
 
@@ -448,8 +497,11 @@ void UIElement::focusChild(UIElement *child) {
 }
 
 void UIElement::addFocusChild(UIElement *element) {
-	element->setFocusParent(element);
-	focusChildren.push_back(element);
+    if(element->isFocusable()) {
+        element->setFocusParent(this);
+        focusChildren.push_back(element);
+    }
+    addChild(element);
 }
 
 void UIElement::setFocusParent(UIElement *element) {

+ 3 - 2
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -219,8 +219,8 @@ UITextInput::UITextInput(bool multiLine, Number width, Number height) : UIElemen
 	indentSpacing = 4;
 	indentType = INDENT_TAB;
 	
-	core->getInput()->addEventListener(this, InputEvent::EVENT_KEYDOWN);
-	core->getInput()->addEventListener(this, InputEvent::EVENT_MOUSEUP);
+	core->getInput()->addEventListenerUnique(this, InputEvent::EVENT_KEYDOWN);
+	core->getInput()->addEventListenerUnique(this, InputEvent::EVENT_MOUSEUP);
 }
 
 void UITextInput::checkBufferLines() {
@@ -2607,6 +2607,7 @@ void UITextInput::handleEvent(Event *event) {
 		}
 	}
 	
+    UIElement::handleEvent(event);
 }
 
 void UITextInput::shiftText(bool left) {

+ 1 - 7
Modules/Contents/UI/Source/PolyUIWindow.cpp

@@ -131,13 +131,7 @@ UIWindow::~UIWindow() {
 	CoreServices::getInstance()->getCore()->getInput()->removeAllHandlersForListener(this);
 }
 
-void UIWindow::onKeyDown(PolyKEY key, wchar_t charCode) {
-	if(key == KEY_TAB) {
-		if(hasFocus) {
-			focusNextChild();
-		}
-	}
-	
+void UIWindow::onKeyDown(PolyKEY key, wchar_t charCode) {	
 	if(key == KEY_ESCAPE && closeOnEscape) {
 		onClose();
 		dispatchEvent(new UIEvent(), UIEvent::CLOSE_EVENT);