From d2474edf85674aa4fb150caee184fc434915d5e6 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Tue, 28 Sep 2010 17:47:24 +0100
Subject: restore switching logic between textbox/nontextbox, after the
 refactor.

---
 indra/newview/llscriptfloater.cpp | 29 ++++++++++++++++++++++++++---
 indra/newview/llscriptfloater.h   |  3 ++-
 2 files changed, 28 insertions(+), 4 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp
index 678611a943..825ee0823d 100644
--- a/indra/newview/llscriptfloater.cpp
+++ b/indra/newview/llscriptfloater.cpp
@@ -32,6 +32,7 @@
 #include "llchannelmanager.h"
 #include "llchiclet.h"
 #include "llfloaterreg.h"
+#include "lllslconstants.h"
 #include "llnotifications.h"
 #include "llnotificationsutil.h"
 #include "llscreenchannel.h"
@@ -152,7 +153,7 @@ void LLScriptFloater::createForm(const LLUUID& notification_id)
 
 	// create new form
 	LLRect toast_rect = getRect();
-	if (isScriptTextbox())
+	if (isScriptTextbox(notification))
 	{
 		mScriptForm = new LLToastScriptTextbox(notification);
 	}
@@ -575,9 +576,31 @@ void LLScriptFloaterManager::setFloaterVisible(const LLUUID& notification_id, bo
 
 //////////////////////////////////////////////////////////////////
 
-bool  LLScriptFloater::isScriptTextbox()
+bool LLScriptFloater::isScriptTextbox(LLNotificationPtr notification)
 {
-	return true;
+	// get a form for the notification
+	LLNotificationFormPtr form(notification->getForm());
+
+	if (form)
+	{
+		// get number of elements
+		int num_options = form->getNumElements();
+	
+		// if ANY of the buttons have the magic lltextbox string as name, then
+		// treat the whole dialog as a simple text entry box (i.e. mixed button
+		// and textbox forms are not supported)
+		for (int i=0; i<num_options; ++i)
+		{
+			LLSD form_element = form->getElement(i);
+			llwarns << form_element << llendl;
+			if (form_element["name"].asString() == TEXTBOX_MAGIC_TOKEN)
+			{
+				return true;
+			}
+		}
+	}
+
+	return false;
 }
 
 // EOF
diff --git a/indra/newview/llscriptfloater.h b/indra/newview/llscriptfloater.h
index fec81704d8..dc52baa115 100644
--- a/indra/newview/llscriptfloater.h
+++ b/indra/newview/llscriptfloater.h
@@ -28,6 +28,7 @@
 #define LL_SCRIPTFLOATER_H
 
 #include "lltransientdockablefloater.h"
+#include "llnotificationptr.h"
 
 class LLToastNotifyPanel;
 
@@ -203,7 +204,7 @@ protected:
 	void dockToChiclet(bool dock);
 
 private:
-	bool isScriptTextbox();
+	bool isScriptTextbox(LLNotificationPtr notification);
 
 	LLToastNotifyPanel* mScriptForm;
 	LLUUID mNotificationId;
-- 
cgit v1.2.3