2003-12-30 22:09:42 +00:00
|
|
|
// Subclass.cs - Widget subclass Test
|
2002-12-25 00:36:00 +00:00
|
|
|
//
|
2003-12-30 22:09:42 +00:00
|
|
|
// Author: Mike Kestner <mkestner@ximian.com>
|
2002-12-25 00:36:00 +00:00
|
|
|
//
|
2003-12-30 22:09:42 +00:00
|
|
|
// (c) 2001-2003 Mike Kestner, Novell, Inc.
|
2002-12-25 00:36:00 +00:00
|
|
|
|
|
|
|
namespace GtkSamples {
|
|
|
|
|
|
|
|
using Gtk;
|
|
|
|
using System;
|
|
|
|
|
2013-10-24 10:57:42 +00:00
|
|
|
public class ButtonAppSubclass {
|
2002-12-25 00:36:00 +00:00
|
|
|
|
|
|
|
public static int Main (string[] args)
|
|
|
|
{
|
|
|
|
Application.Init ();
|
|
|
|
Window win = new Window ("Button Tester");
|
2004-02-02 21:32:54 +00:00
|
|
|
win.DeleteEvent += new DeleteEventHandler (Quit);
|
2002-12-25 00:36:00 +00:00
|
|
|
Button btn = new MyButton ();
|
|
|
|
win.Add (btn);
|
|
|
|
win.ShowAll ();
|
|
|
|
Application.Run ();
|
|
|
|
return 0;
|
|
|
|
}
|
2004-02-02 21:32:54 +00:00
|
|
|
|
|
|
|
static void Quit (object sender, DeleteEventArgs args)
|
|
|
|
{
|
|
|
|
Application.Quit();
|
|
|
|
}
|
2002-12-25 00:36:00 +00:00
|
|
|
}
|
|
|
|
|
2004-12-23 22:59:59 +00:00
|
|
|
[Binding (Gdk.Key.Escape, "HandleBinding", "Escape")]
|
|
|
|
[Binding (Gdk.Key.Left, "HandleBinding", "Left")]
|
|
|
|
[Binding (Gdk.Key.Right, "HandleBinding", "Right")]
|
|
|
|
[Binding (Gdk.Key.Up, "HandleBinding", "Up")]
|
|
|
|
[Binding (Gdk.Key.Down, "HandleBinding", "Down")]
|
2002-12-25 00:36:00 +00:00
|
|
|
public class MyButton : Gtk.Button {
|
|
|
|
|
2004-05-07 13:42:59 +00:00
|
|
|
public MyButton () : base ("I'm a subclassed button") {}
|
2003-12-30 22:09:42 +00:00
|
|
|
|
|
|
|
protected override void OnClicked ()
|
|
|
|
{
|
|
|
|
Console.WriteLine ("Button::Clicked default handler fired.");
|
|
|
|
}
|
2004-12-23 22:59:59 +00:00
|
|
|
|
|
|
|
private void HandleBinding (string text)
|
|
|
|
{
|
|
|
|
Console.WriteLine ("Got a bound keypress: " + text);
|
|
|
|
}
|
2002-12-25 00:36:00 +00:00
|
|
|
}
|
|
|
|
}
|