Example #1
0
void UserWindow::ReadChooserDialogObject(
	SharedKObject o,
	bool& multiple,
	std::string& title,
	std::string& path,
	std::string& defaultName,
	std::vector<std::string>& types,
	std::string& typesDescription)

{
	// Pass in a set of properties for chooser dialogs like this:
	// var selected = Titanium.UI.OpenFileChooserDialog(callback,
	// {
	//    multiple:true,
	//    title: "Select file to delete...",
	//    defaultFile: "autoexec.bat",
	//    path: "C:\"
	//    types:['js','html']
	// });
	multiple = o->GetBool("multiple", true);
	title = o->GetString("title", title);
	path = o->GetString("path", path);
	defaultName = o->GetString("defaultName", defaultName);

	SharedKList listTypes = new StaticBoundList();
	listTypes = o->GetList("types", listTypes);
	for (size_t i = 0; i < listTypes->Size(); i++)
	{
		if (listTypes->At(i)->IsString())
		{
			types.push_back(listTypes->At(i)->ToString());
			std::cout << "Found " << listTypes->At(i)->ToString() << std::endl;
		}
	}
	typesDescription = o->GetString("typesDescription", defaultName);

}
	void MonkeyBinding::Callback(const ValueList &args, SharedValue result)
	{
		SharedKObject event = args.at(0)->ToObject();
		if (!event->Get("url")->IsString() ||
			!event->Get("scope")->IsObject() ||
			!event->GetObject("scope")->Get("window"))
		{
			throw ValueException::FromString(
				"ti.Monkey could not find required components of PAGE_LOADED events");
		}

		std::string url = event->GetString("url");
		SharedKObject windowObject = event->GetObject("scope")->GetObject("window");
		vector<Script*>::iterator iter = scripts.begin();
		while (iter != scripts.end())
		{
			Script* script = (*iter++);
			if (script->Matches(url))
			{
				EvaluateUserScript(event, url, windowObject, script->source);
			}
		}
	}