0

我试着捕捉这样的事件......

class ExposedWebView : WebKit.WebView {
    public event EventHandler Create
    {
        add
        {
            Signal signal = Signal.Lookup (this, "create");
            signal.AddDelegate (value);
        }
        remove
        {
            Signal signal = Signal.Lookup (this, "create");
            signal.RemoveDelegate (value);
        }
    }
}

但是当我尝试创建处理程序时出现错误...

GLib-GObject-WARNING **:gsignal.c:2375:create' is invalid for instance类型为“__gtksharp_1_ExposedWebView”的信号 0x20e8020'

任何人都知道为什么这不起作用?是否有另一种方法可以让弹出对话框在 WebView 中工作?

4

1 回答 1

0

我必须加入创建网络视图,而不是“创建”......

ExposedWebView webView = new ExposedWebView();
webView.CreateWebView += HandleCreateWebView;

    void HandleCreateWebView (object o, CreateWebViewArgs args)
    {
        Window info = new Window("");
        info.DefaultWidth = 1000;
        info.DefaultHeight = 700;
        VBox vbox2 = new VBox();
        WebView child = new WebView();
        child.NavigationRequested += HandleNavigationRequested1;
        vbox2.PackStart(child);
        info.Add (vbox2);
        info.ShowAll();
        args.RetVal = child;
    }


class ExposedWebView : WebKit.WebView {
    public event CreateWebViewHandler CreateWebView
    {
        add
        {
            Signal signal = Signal.Lookup (this, "create-web-view", typeof(CreateWebViewArgs));
            signal.AddDelegate (value);
        }
        remove
        {
            Signal signal = Signal.Lookup (this, "create-web-view", typeof(CreateWebViewArgs));
            signal.RemoveDelegate (value);
        }
    }

    [DefaultSignalHandler (Type = typeof(WebView), ConnectionMethod = "OverrideCreateWebView")]
    protected virtual WebView OnCreateWebView (WebFrame frame)
    {
        ExposedWebView webView = new ExposedWebView();
        Value empty = Value.Empty;
        ValueArray valueArray = new ValueArray (2u);
        Value[] array = new Value[2];
        array [0] = new Value (this);
        valueArray.Append (array [0]);
        array [1] = new Value (frame);
        valueArray.Append (array [1]);
        GLib.Object.g_signal_chain_from_overridden (valueArray.ArrayPtr, ref empty);
        Value[] array2 = array;
        for (int i = 0; i < array2.Length; i++)
        {
            Value value = array2 [i];
            value.Dispose ();
        }
        return webView;
    }
}

public delegate void CreateWebViewHandler (object o, CreateWebViewArgs args);

public class CreateWebViewArgs : SignalArgs
{
    //
    // Properties
    //

    public WebFrame Frame
    {
        get
        {
            return (WebFrame)base.Args [0];
        }
    }
}
于 2013-07-02T21:40:46.427 回答