Fix scrolling functionality
[WebThing.git] / plugins / MiddleClickOpen.cs
1 using System;
2 using Gtk;
3 using WebKit;
4 using bytex64.WebThing;
5
6 public class MiddleClickOpen : WebThingPlugin {
7     private string LinkUri = null;
8     private WebThing wt;
9     
10     public override void Init(WebThing wt) {
11         this.wt = wt;
12     }
13
14     public override void InitWebView(WebView wv) {
15         wv.HoveringOverLink += delegate(object o, HoveringOverLinkArgs e) {
16             LinkUri = e.Link;
17         };
18
19         wv.ButtonReleaseEvent += WebView_ButtonRelease;
20     }
21
22     private void WebView_ButtonRelease(object o, Gtk.ButtonReleaseEventArgs e) {
23         if (e.Event.Button == 2) {
24             if (LinkUri != null) {
25                 wt.OpenTab(LinkUri);
26                 wt.WebView.StopLoading();
27                 e.RetVal = true;   // WHY DOESN'T THIS WORK!?
28             }
29         }
30     }
31 }