HRESULT STDMETHODCALLTYPE
Win32WebKitUIDelegate::trackCustomPopupMenu(
	/* [in] */ IWebView *sender,
	/* [in] */ OLE_HANDLE inMenu,
	/* [in] */ LPPOINT point)
{
	AutoPtr<Win32Menu> menu = this->window->GetContextMenu().cast<Win32Menu>();

	// No window menu, try to use the application menu.
	if (menu.isNull())
	{
		Win32UIBinding* b = static_cast<Win32UIBinding*>(UIBinding::GetInstance());
		menu = b->GetContextMenu().cast<Win32Menu>();
	}

	if (this->nativeContextMenu) {
		DestroyMenu(this->nativeContextMenu);
		this->nativeContextMenu = 0;
	}

	Host* host = Host::GetInstance();
	if (!menu.isNull()) {
		this->nativeContextMenu = menu->CreateNative(false);

	} else if (host->IsDebugMode()) {
		this->nativeContextMenu = CreatePopupMenu();
		Win32Menu::ApplyNotifyByPositionStyleToNativeMenu(this->nativeContextMenu);
	}

	if (this->nativeContextMenu) {

		if (host->IsDebugMode()) {
			AppendMenu(this->nativeContextMenu, MF_SEPARATOR, 1, L"Separator");
			AppendMenu(this->nativeContextMenu,
				MF_STRING, WEB_INSPECTOR_MENU_ITEM_ID, L"Show Inspector");
		}

		TrackPopupMenu(this->nativeContextMenu,
			TPM_BOTTOMALIGN, point->x, point->y, 0,
			this->window->GetWindowHandle(), NULL);
	}

	return S_OK;
}
Example #2
0
	int Execute(HINSTANCE hInstance, int argc, const char **argv){
		Host *host = new kroll::Win32Host(hInstance,argc,argv);
#ifndef DEBUG
		// only create a debug console when not compiled in debug mode -- otherwise, it should be autocreated

		if (host->IsDebugMode())
		{
			RedirectIOToConsole();
		}
#endif
		return host->Run();
	}