当前位置: 首页>>代码示例>>C++>>正文


C++ WebView::ExecuteJavascriptWithResult方法代码示例

本文整理汇总了C++中WebView::ExecuteJavascriptWithResult方法的典型用法代码示例。如果您正苦于以下问题:C++ WebView::ExecuteJavascriptWithResult方法的具体用法?C++ WebView::ExecuteJavascriptWithResult怎么用?C++ WebView::ExecuteJavascriptWithResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebView的用法示例。


在下文中一共展示了WebView::ExecuteJavascriptWithResult方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnShowPopupMenu

void MenuListener::OnShowPopupMenu(WebView *caller, const WebPopupMenuInfo &menu_info)
{
//	DevMsg("DISABLED FOR TESTING!\n");
//	return;

	//C_WebTab* pWebTab = g_pAnarchyManager->GetWebManager()->GetWebBrowser()->FindWebTab(caller);
	//C_WebTab* pHudWebTab = g_pAnarchyManager->GetWebManager()->GetHudWebTab();
	//WebView* pHudWebView = g_pAnarchyManager->GetWebManager()->GetWebBrowser()->FindWebView(pHudWebTab);

	C_AwesomiumBrowserInstance* pAwesomiumBrowserInstance = g_pAnarchyManager->GetAwesomiumBrowserManager()->FindAwesomiumBrowserInstance(caller);	// FIXME: This should be a general EmbeddedInstance of any type.
	C_AwesomiumBrowserInstance* pHudBrowserInstance = g_pAnarchyManager->GetAwesomiumBrowserManager()->FindAwesomiumBrowserInstance("hud");
	WebView* pHudWebView = pHudBrowserInstance->GetWebView();

	DevMsg("Pop menu detected!\n");

	std::vector<std::string> methodArguments;
	methodArguments.push_back(pAwesomiumBrowserInstance->GetId());
	methodArguments.push_back(VarArgs("%i", menu_info.bounds.x));
	methodArguments.push_back(VarArgs("%i", menu_info.bounds.y));
	methodArguments.push_back(VarArgs("%i", menu_info.bounds.width));
	methodArguments.push_back(VarArgs("%i", menu_info.bounds.height));
	methodArguments.push_back(VarArgs("%i", menu_info.item_height));
	methodArguments.push_back(VarArgs("%f", menu_info.item_font_size));
	methodArguments.push_back(VarArgs("%i", menu_info.selected_item));
	methodArguments.push_back(VarArgs("%i", menu_info.right_aligned));

	for (int i = 0; i < menu_info.items.size(); i++)
	{
		if (menu_info.items[i].type == kWebMenuItemType_Option)
			methodArguments.push_back("Option");
		else if (menu_info.items[i].type == kWebMenuItemType_CheckableOption)
			methodArguments.push_back("CheckableOption");
		else if (menu_info.items[i].type == kWebMenuItemType_Group)
			methodArguments.push_back("Group");
		else if (menu_info.items[i].type == kWebMenuItemType_Separator)
			methodArguments.push_back("Separator");

		methodArguments.push_back(WebStringToCharString(menu_info.items[i].label));
		methodArguments.push_back(WebStringToCharString(menu_info.items[i].tooltip));
		methodArguments.push_back(VarArgs("%i", menu_info.items[i].action));
		methodArguments.push_back(VarArgs("%i", menu_info.items[i].right_to_left));
		methodArguments.push_back(VarArgs("%i", menu_info.items[i].has_directional_override));
		methodArguments.push_back(VarArgs("%i", menu_info.items[i].enabled));
		methodArguments.push_back(VarArgs("%i", menu_info.items[i].checked));
	}
	
	std::string objectName = "window.arcadeHud";
	std::string objectMethod = "showPopupMenu";

	JSValue response = pHudWebView->ExecuteJavascriptWithResult(WSLit(objectName.c_str()), WSLit(""));
	if (response.IsObject())
	{
		JSObject object = response.ToObject();
		JSArray arguments;

		for (auto argument : methodArguments)
			arguments.Push(WSLit(argument.c_str()));

		object.InvokeAsync(WSLit(objectMethod.c_str()), arguments);
	}
}
开发者ID:smsithlord,项目名称:AArcade-Source,代码行数:61,代码来源:c_awesomiumlisteners.cpp


注:本文中的WebView::ExecuteJavascriptWithResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。