/// <summary> /// Trap widget events to get a left button mouse click. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="args">Event arguments.</param> private void OnWidgetEventAfter(object sender, WidgetEventAfterArgs args) { try { if (args.Event.Type == Gdk.EventType.ButtonRelease) { Gdk.EventButton evt = (Gdk.EventButton)args.Event; if (evt.Button == 1) { // we shouldn't follow a link if the user has selected something textView.Buffer.GetSelectionBounds(out TextIter start, out TextIter end); if (start.Offset == end.Offset) { textView.WindowToBufferCoords(TextWindowType.Widget, (int)evt.X, (int)evt.Y, out int x, out int y); TextIter iter = textView.GetIterAtLocation(x, y); foreach (var tag in iter.Tags) { if (tag is LinkTag linkTag) { Process.Start(linkTag.URL); } } } } } } catch (Exception err) { ShowError(err); } }
// Links can also be activated by clicking. void EventAfter(object sender, WidgetEventAfterArgs args) { if (args.Event.Type != Gdk.EventType.ButtonRelease) { return; } Gdk.EventButton evt = (Gdk.EventButton)args.Event; if (evt.Button != 1) { return; } TextView view = sender as TextView; TextIter start, end, iter; int x, y; // we shouldn't follow a link if the user has selected something view.Buffer.GetSelectionBounds(out start, out end); if (start.Offset != end.Offset) { return; } view.WindowToBufferCoords(TextWindowType.Widget, (int)evt.X, (int)evt.Y, out x, out y); iter = view.GetIterAtLocation(x, y); FollowIfLink(view, iter); }
private void OnWidgetEventAfter(object o, WidgetEventAfterArgs args) { if (args.Event.Type != Gdk.EventType.Scroll) { return; } try { g_signal_stop_emission_by_name(Handle, "event-after"); } catch (DllNotFoundException) { WarnGObjectMap(); g_signal_stop_emission_by_name_fallback(Handle, "event-after"); } }
/// <summary> /// Trap widget events to get a left button mouse click. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="args">Event arguments.</param> private void OnWidgetEventAfter(object sender, WidgetEventAfterArgs args) { try { if (args.Event.Type == Gdk.EventType.ButtonRelease) { Gdk.EventButton evt = (Gdk.EventButton)args.Event; if (evt.Button == 1) { // we shouldn't follow a link if the user has selected something textView.Buffer.GetSelectionBounds(out TextIter start, out TextIter end); if (start.Offset == end.Offset) { textView.WindowToBufferCoords(TextWindowType.Widget, (int)evt.X, (int)evt.Y, out int x, out int y); TextIter iter = textView.GetIterAtLocation(x, y); // fixme: When we remove gtk2 deps, we can eliminate this check if (iter.Equals(TextIter.Zero)) { return; } foreach (var tag in iter.Tags) { if (tag is LinkTag linkTag) { // convert modified absolute paths in links for parser acceptance back to real link // allows tags in URL to link to absolute c: path if (linkTag.URL.Contains("[drive]")) { linkTag.URL = linkTag.URL.Replace("[drive]", ":"); linkTag.URL = linkTag.URL.Replace("../", "/"); } ProcessUtilities.ProcessStart(linkTag.URL); } } } } } } catch (Exception err) { ShowError(err); } }
void OnWidgetEvent(object o, WidgetEventAfterArgs args) { if (args.Event.Type == Gdk.EventType.Expose && o is TextView && args.Event.Window == view.GetWindow(TextWindowType.Text)) { int x, y; view.WindowToBufferCoords(TextWindowType.Text, args.Event.Window.ClipRegion.Clipbox.X, args.Event.Window.ClipRegion.Clipbox.Y, out x, out y); TextIter start, end; int topLine; view.GetLineAtY(out start, y, out topLine); view.GetLineAtY(out end, y + args.Event.Window.ClipRegion.Clipbox.Height, out topLine); end.ForwardToLineEnd(); Draw(args.Event.Window, view, start, end); } }
void EventAfter(object sender, WidgetEventAfterArgs args) { if (args.Event.Type != Gdk.EventType.ButtonRelease) return; Gdk.EventButton evt = (Gdk.EventButton) args.Event; if (evt.Button != 1) return; TextView view = sender as TextView; TextIter start, end, iter; int x, y; // we shouldn't follow a link if the user has selected something view.Buffer.GetSelectionBounds (out start, out end); if (start.Offset != end.Offset) return; view.WindowToBufferCoords (TextWindowType. Widget, (int) evt.X, (int) evt.Y, out x, out y); iter = view.GetIterAtLocation (x, y); FollowIfLink (view, iter); }
void OnEventAfter(object sender, WidgetEventAfterArgs args) { if (args.Event.Type != Gdk.EventType.ButtonRelease) return; Gdk.EventButton evt = (Gdk.EventButton) args.Event; if (evt.Button != 1) return; int x, y; ConvertToGraphCoords ((int) evt.X, (int) evt.Y, out x, out y); GraphPoint matching; if (MatchingPoint (x, y, point_size - inter_point_gap, out matching)) { if (GameClickedEvent != null) GameClickedEvent (this, matching. info); } }