Procházet zdrojové kódy

Expose MessageBox's window element to scripting for manipulation.

Yao Wei Tjong 姚伟忠 před 12 roky
rodič
revize
3383bf109b

+ 1 - 1
Bin/Data/UI/MessageBox.xml

@@ -13,7 +13,7 @@
 		<attribute name="Layout Mode" value="Horizontal" />
 		<element type="Text">
 			<attribute name="Name" value="TitleText" />
-            <attribute name="Text" value="Urho3D" />
+			<attribute name="Text" value="Urho3D" />
 		</element>
 		<element type="Button" style="CloseButton">
 			<attribute name="Name" value="CloseButton" />

+ 4 - 2
Source/Engine/LuaScript/pkgs/UI/MessageBox.pkg

@@ -7,10 +7,12 @@ class MessageBox : public Object
 
     void SetTitle(const String& text);
     void SetMessage(const String& text);
-    
+
     const String GetTitle() const;
     const String GetMessage() const;
-       
+    Window* GetWindow() const;
+
     tolua_property__get_set String& title;
     tolua_property__get_set String& message;
+    tolua_readonly tolua_property__get_set Window* window;
 };

+ 1 - 0
Source/Engine/Script/UIAPI.cpp

@@ -448,6 +448,7 @@ static void RegisterMessageBox(asIScriptEngine* engine)
     engine->RegisterObjectMethod("MessageBox", "const String& get_title() const", asMETHOD(MessageBox, GetTitle), asCALL_THISCALL);
     engine->RegisterObjectMethod("MessageBox", "void set_message(const String&in)", asMETHOD(MessageBox, SetMessage), asCALL_THISCALL);
     engine->RegisterObjectMethod("MessageBox", "const String& get_message() const", asMETHOD(MessageBox, GetMessage), asCALL_THISCALL);
+    engine->RegisterObjectMethod("MessageBox", "Window@+ get_window() const", asMETHOD(MessageBox, GetWindow), asCALL_THISCALL);
 }
 
 static CScriptArray* DropDownListGetItems(DropDownList* ptr)

+ 2 - 0
Source/Engine/UI/MessageBox.h

@@ -54,6 +54,8 @@ public:
     const String& GetTitle() const;
     /// Return message text. Return empty string if there is no message text element.
     const String& GetMessage() const;
+    /// Return dialog window.
+    Window* GetWindow() const { return window_; }
 
 private:
     /// Handle events that dismiss the message box.

+ 0 - 1
Source/Engine/UI/Window.cpp

@@ -248,7 +248,6 @@ void Window::SetResizeBorder(const IntRect& rect)
 
 void Window::SetModal(bool modal)
 {
-    // UI may be null at shutdown if for example a script was holding a reference to this window
     UI* ui = GetSubsystem<UI>();
     if (ui->SetModalElement(this, modal))
     {