mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-30 02:53:11 +02:00
Add FormBrowser.InvokeSafe and use it for CEF callbacks
This commit is contained in:
@@ -81,6 +81,15 @@ namespace TweetDick.Core{
|
||||
|
||||
// callback handlers
|
||||
|
||||
public void InvokeSafe(Action func){
|
||||
if (InvokeRequired){
|
||||
Invoke(func);
|
||||
}
|
||||
else{
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenSettings(){
|
||||
// TODO
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using CefSharp;
|
||||
using System;
|
||||
|
||||
namespace TweetDick.Core.Handling{
|
||||
class ContextMenuHandler : IContextMenuHandler{
|
||||
@@ -31,11 +32,17 @@ namespace TweetDick.Core.Handling{
|
||||
public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags){
|
||||
switch((int)commandId){
|
||||
case MenuSettings:
|
||||
form.OpenSettings();
|
||||
form.InvokeSafe(() => {
|
||||
form.OpenSettings();
|
||||
});
|
||||
|
||||
return true;
|
||||
|
||||
case MenuAbout:
|
||||
form.OpenAbout();
|
||||
form.InvokeSafe(() => {
|
||||
form.OpenAbout();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,9 @@
|
||||
}
|
||||
|
||||
public void OpenSettingsMenu(){
|
||||
form.OpenSettings();
|
||||
form.InvokeSafe(() => {
|
||||
form.OpenSettings();
|
||||
});
|
||||
}
|
||||
|
||||
public void Log(string data){
|
||||
|
Reference in New Issue
Block a user