Browse Source

Command for GuiDropDownCtrl

Add command support to GuiDropDownCtrl. The control now fires the command anytime a selection is made. The text and be quickly gathered with getText();
Peter Robinson 4 years ago
parent
commit
cc9d46e538

+ 3 - 0
engine/source/gui/buttons/guiDropDownCtrl.cc

@@ -50,6 +50,9 @@ void GuiDropDownListBoxCtrl::addSelection(LBItem *item, S32 index)
 {
 	Parent::addSelection(item, index);
 
+	if (mConsoleCommand[0])
+		Con::evaluate(mConsoleCommand, false);
+
 	mDropDownCtrl->closeDropDown();
 }
 #pragma endregion

+ 8 - 0
engine/source/gui/buttons/guiDropDownCtrl_ScriptBinding.h

@@ -338,6 +338,14 @@ ConsoleMethodWithDocs(GuiDropDownCtrl, getItemText, ConsoleString, 3, 3, "(S32 i
 	return object->getList()->getItemText(dAtoi(argv[2]));
 }
 
+/*! Returns the text of the selected item.
+	@return The text of the selected item.
+*/
+ConsoleMethodWithDocs(GuiDropDownCtrl, getText, ConsoleString, 3, 3, "()")
+{
+	return object->getList()->getItemText(object->getList()->getSelectedItem());
+}
+
 /*! Sets the text of the item at the given item index.
 	@param index The zero-based index of the item that will be updated.
 	@param text The text value to update with.