fix flash menu being unresponsive to commands
This commit is contained in:
		
					parent
					
						
							
								85ef42d99e
							
						
					
				
			
			
				commit
				
					
						c586806609
					
				
			
		
					 5 changed files with 19 additions and 3 deletions
				
			
		|  | @ -40,6 +40,7 @@ void Menu::AfterInit(v8::Isolate* isolate) { | |||
|   delegate.Get("getAcceleratorForCommandId", &get_accelerator_); | ||||
|   delegate.Get("executeCommand", &execute_command_); | ||||
|   delegate.Get("menuWillShow", &menu_will_show_); | ||||
|   delegate.Get("menuClosed", &menu_closed_); | ||||
| } | ||||
| 
 | ||||
| bool Menu::IsCommandIdChecked(int command_id) const { | ||||
|  | @ -75,6 +76,10 @@ void Menu::MenuWillShow(ui::SimpleMenuModel* source) { | |||
|   menu_will_show_.Run(); | ||||
| } | ||||
| 
 | ||||
| void Menu::MenuClosed(ui::SimpleMenuModel* source) { | ||||
|   menu_closed_.Run(); | ||||
| } | ||||
| 
 | ||||
| void Menu::InsertItemAt( | ||||
|     int index, int command_id, const base::string16& label) { | ||||
|   model_->InsertItemAt(index, command_id, label); | ||||
|  |  | |||
|  | @ -52,6 +52,7 @@ class Menu : public mate::TrackableObject<Menu>, | |||
|       ui::Accelerator* accelerator) const override; | ||||
|   void ExecuteCommand(int command_id, int event_flags) override; | ||||
|   void MenuWillShow(ui::SimpleMenuModel* source) override; | ||||
|   void MenuClosed(ui::SimpleMenuModel* source) override; | ||||
| 
 | ||||
|   virtual void PopupAt(Window* window, int x, int y, int positioning_item) = 0; | ||||
|   virtual void ClosePopupAt(int32_t window_id) = 0; | ||||
|  | @ -93,6 +94,7 @@ class Menu : public mate::TrackableObject<Menu>, | |||
|   base::Callback<v8::Local<v8::Value>(int, bool)> get_accelerator_; | ||||
|   base::Callback<void(v8::Local<v8::Value>, int)> execute_command_; | ||||
|   base::Callback<void()> menu_will_show_; | ||||
|   base::Callback<void()> menu_closed_; | ||||
| 
 | ||||
|   DISALLOW_COPY_AND_ASSIGN(Menu); | ||||
| }; | ||||
|  |  | |||
|  | @ -653,8 +653,10 @@ void WebContents::RendererResponsive(content::WebContents* source) { | |||
| 
 | ||||
| bool WebContents::HandleContextMenu(const content::ContextMenuParams& params) { | ||||
|   if (params.custom_context.is_pepper_menu) { | ||||
|     Emit("pepper-context-menu", std::make_pair(params, web_contents())); | ||||
|     web_contents()->NotifyContextMenuClosed(params.custom_context); | ||||
|     Emit("pepper-context-menu", | ||||
|       std::make_pair(params, web_contents()), | ||||
|       base::Bind(&content::WebContents::NotifyContextMenuClosed, | ||||
|         base::Unretained(web_contents()), params.custom_context)); | ||||
|   } else { | ||||
|     Emit("context-menu", std::make_pair(params, web_contents())); | ||||
|   } | ||||
|  |  | |||
|  | @ -39,6 +39,9 @@ Menu.prototype._init = function () { | |||
|         const found = this.groupsMap[id].find(item => item.checked) || null | ||||
|         if (!found) v8Util.setHiddenValue(this.groupsMap[id][0], 'checked', true) | ||||
|       } | ||||
|     }, | ||||
|     menuClosed: () => { | ||||
|       this.emit('closed') | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -277,10 +277,14 @@ WebContents.prototype._init = function () { | |||
|   }) | ||||
| 
 | ||||
|   // Handle context menu action request from pepper plugin.
 | ||||
|   this.on('pepper-context-menu', function (event, params) { | ||||
|   this.on('pepper-context-menu', function (event, params, callback) { | ||||
|     // Access Menu via electron.Menu to prevent circular require
 | ||||
|     const menu = electron.Menu.buildFromTemplate(params.menu) | ||||
|     menu.popup(event.sender.getOwnerBrowserWindow(), params.x, params.y) | ||||
| 
 | ||||
|     menu.on('closed', () => { | ||||
|       callback() | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|   // The devtools requests the webContents to reload.
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Heilig Benedek
				Heilig Benedek