Просмотр исходного кода

All tool windows now focus automatically on popup, text input popup automatically selects existing text for convenience

Ivan Safrin 10 лет назад
Родитель
Сommit
b6b2dc7d22

+ 10 - 0
IDE/Contents/Include/ToolWindows.h

@@ -39,6 +39,8 @@ class TextInputPopup : public UIWindow {
 		String getValue();
 		void handleEvent(Event *event);
 		
+        virtual void onGainFocus();
+    
 		String action;
 				
 	protected:
@@ -57,6 +59,8 @@ class MessagePopup : public UIWindow {
     void setCaption(String caption);
     void handleEvent(Event *event);
     
+    virtual void onGainFocus();
+    
         String action;
         UILabel *captionLabel;
         UIButton *okButton;
@@ -71,6 +75,8 @@ class YesNoPopup : public UIWindow {
 		void setCaption(String caption);
 		void handleEvent(Event *event);
 		
+        virtual void onGainFocus();
+    
 		String action;
 	
 		UILabel *captionLabel;
@@ -89,6 +95,8 @@ class YesNoCancelPopup : public UIWindow {
 		void setCaption(String caption);
 		void handleEvent(Event *event);
 		
+        virtual void onGainFocus();
+    
 		String action;
 	
 		UILabel *captionLabel;
@@ -110,6 +118,8 @@ class AssetImporterWindow : public UIWindow {
 		
 		void setSourceFileAndTargetFolder(String file, String folder, String projectRelativeFolder);
 		void refreshPreview();
+    
+        virtual void onGainFocus();
 			
 		void handleEvent(Event *event);	
 			

+ 2 - 3
IDE/Contents/Source/PolycodeFrame.cpp

@@ -1526,9 +1526,8 @@ void PolycodeFrame::showModal(UIWindow *modalChild) {
 	modalChild->addEventListener(this, UIEvent::CLOSE_EVENT);
 	Resize(getWidth(), getHeight());
 	
-	if(modalChild == yesNoPopup) {
-		yesNoPopup->focusChild(yesNoPopup->okButton);
-	}
+    modalChild->focusSelf();
+    
 	CoreServices::getInstance()->getCore()->setCursor(Core::CURSOR_ARROW);	
 }
 

+ 21 - 1
IDE/Contents/Source/ToolWindows.cpp

@@ -40,13 +40,17 @@ TextInputPopup::TextInputPopup() : UIWindow(L"", 300, 80) {
 	okButton->setPosition(padding+300-100, 64);
 	
 	closeOnEscape = true;
-
 }
 
 void TextInputPopup::setCaption(String caption) {
 	setWindowCaption(caption);
 }
 
+void TextInputPopup::onGainFocus() {
+    focusChild(textInput);
+    textInput->selectAll();
+}
+
 String TextInputPopup::getValue() {
 	return textInput->getText();
 }
@@ -93,6 +97,10 @@ MessagePopup::~MessagePopup() {
     
 }
 
+void MessagePopup::onGainFocus() {
+    focusChild(okButton);
+}
+
 void MessagePopup::setCaption(String caption) {
 	captionLabel->setText(caption);
 	
@@ -141,6 +149,10 @@ YesNoPopup::YesNoPopup() : UIWindow(L"", 300, 80) {
 
 }
 
+void YesNoPopup::onGainFocus() {
+    focusChild(okButton);
+}
+
 void YesNoPopup::setCaption(String caption) {
 	captionLabel->setText(caption);
 	
@@ -173,6 +185,10 @@ YesNoPopup::~YesNoPopup() {
 	
 }
 
+void YesNoCancelPopup::onGainFocus() {
+    focusChild(okButton);
+}
+
 YesNoCancelPopup::YesNoCancelPopup() : UIWindow(L"", 300, 80) {
 	
 	captionLabel = new UILabel("This is a caption", 12);	
@@ -331,6 +347,10 @@ AssetImporterWindow::AssetImporterWindow() : UIWindow("3D Asset Importer", 650,
     
 }
 
+void AssetImporterWindow::onGainFocus() {
+    focusChild(okButton);
+}
+
 void AssetImporterWindow::handleEvent(Event *event) {
     if(!enabled) {
         return;