فهرست منبع

Merge remote-tracking branch 'upstream/development' into development

marauder2k7 4 سال پیش
والد
کامیت
795a45993a

+ 15 - 2
engine/source/gui/buttons/guiDropDownCtrl.cc

@@ -50,8 +50,7 @@ void GuiDropDownListBoxCtrl::addSelection(LBItem *item, S32 index)
 {
 	Parent::addSelection(item, index);
 
-	if (mConsoleCommand[0])
-		Con::evaluate(mConsoleCommand, false);
+	mDropDownCtrl->itemSelected();
 
 	mDropDownCtrl->closeDropDown();
 }
@@ -200,6 +199,20 @@ void GuiDropDownCtrl::onRender(Point2I offset, const RectI& updateRect)
 	}
 }
 
+void GuiDropDownCtrl::onAction() //called when the button is clicked.
+{
+	if (!mActive)
+		return;
+
+	setUpdate();
+}
+
+void GuiDropDownCtrl::itemSelected()
+{
+	if (mConsoleCommand[0])
+		Con::evaluate(mConsoleCommand, false);
+}
+
 void GuiDropDownCtrl::openDropDown()
 {
 	if (mIsOpen)

+ 2 - 0
engine/source/gui/buttons/guiDropDownCtrl.h

@@ -91,6 +91,8 @@ public:
    GuiControlState getCurrentState();
    void onRender(Point2I offset, const RectI &updateRect);
 
+   virtual void onAction();
+   void itemSelected();
    void openDropDown();
    void closeDropDown();
 

+ 7 - 2
engine/source/gui/buttons/guiDropDownCtrl_ScriptBinding.h

@@ -341,9 +341,14 @@ ConsoleMethodWithDocs(GuiDropDownCtrl, getItemText, ConsoleString, 3, 3, "(S32 i
 /*! Returns the text of the selected item.
 	@return The text of the selected item.
 */
-ConsoleMethodWithDocs(GuiDropDownCtrl, getText, ConsoleString, 3, 3, "()")
+ConsoleMethodWithDocs(GuiDropDownCtrl, getText, ConsoleString, 2, 2, "()")
 {
-	return object->getList()->getItemText(object->getList()->getSelectedItem());
+	S32 index = object->getList()->getSelectedItem();
+	if(index != -1)
+	{
+		return object->getList()->getItemText(index);
+	}
+	return "";
 }
 
 /*! Sets the text of the item at the given item index.