[Gtk-sharp-list] connect_after issues

Thiago Milczarek Say„o sayao@brturbo.com
Wed, 18 Feb 2004 19:15:24 -0300

Content-Type: text/plain
Content-Transfer-Encoding: 7bit


I still wonder why people would want to connect_after things ??
As a gtk binding, gtk# should follow what is standard in gtk which is
connect_before. (see g_signal_connect ()).

I was told at #mono that i could connect_before extending the class and
overriding the event method. That doesn't work. See the example

So, what if i want to make the Enter key of a TextView process something
instead of making a new line ? (A very common thing) P/Invoke it ?
Afaik, gtk# was made so i don't have to p/invoke things (beside making
things easier).

Mike Kestner, please take a look at it :) It's very important that
people can write gtk# programs easily, and in my opinion this
connect_after  just make things harder.

The example can be compiled with:

mcs TestEvent.cs -o TestEvent.exe /r:gtk-sharp.dll /r:gnome-sharp.dll

(using gtk-sharp from cvs)

Big Hug.

Content-Disposition: attachment; filename=TestEvent.cs
Content-Type: text/x-csharp; name=TestEvent.cs; charset=UTF-8
Content-Transfer-Encoding: 7bit

using System;
using Gtk;
using Gdk;
using GtkSharp;
using Gnome;

class MyTextView : TextView
	public MyTextView () : base ()


	protected override bool OnKeyPressEvent (ref Gdk.EventKey evnt)
		Console.WriteLine ("OnKeyPressEvent");

		return base.OnKeyPressEvent (ref evnt);

class EventTest
	TextView tv;
	static void Main ()
		new EventTest ();
	EventTest ()
		Application.Init ();
		Gtk.Window win = new Gtk.Window ("Event Sample");
		win.SetDefaultSize (400, 300);
		win.DeleteEvent += new DeleteEventHandler (OnWinDelete);
		VBox vbox = new VBox (false, 0);
		win.Add (vbox);
		tv = new MyTextView ();
		tv.Buffer.Text = "Hello World";
		tv.KeyPressEvent += new KeyPressEventHandler (OnKeyPress);
		vbox.PackStart (tv, true, true, 0);

		win.ShowAll ();
		Application.Run ();
	void OnKeyPress (object o, KeyPressEventArgs args)
		Console.WriteLine ("KeyPress");
	void OnWinDelete (object o, DeleteEventArgs args)
		Application.Quit ();