gtk-sharp2.12.0.0Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details.A widget that creates a signal when clicked on.
The widget is generally used to attach to a function that is called when the button is pressed.
The widget can hold any valid child widget.
That is, it can hold most any other standard . The most commonly used child is the .
using Gtk;
using System;
public class ButtonApp {
public static int Main (string[] args)
{
Application.Init ();
Window win = new Window ("Button Tester");
win.SetDefaultSize (200, 150);
win.DeleteEvent += new DeleteEventHandler (Window_Delete);
Button btn = new Button ("Click Me");
btn.Clicked += new EventHandler (btn_click);
win.Add (btn);
win.ShowAll ();
Application.Run ();
return 0;
}
static void btn_click (object obj, EventArgs args)
{
Console.WriteLine ("Button Clicked");
}
static void Window_Delete (object obj, DeleteEventArgs args)
{
Application.Quit ();
args.RetVal = true;
}
}
Gtk.BinPropertySystem.BooleanWhether the should use a .Gets a value indicating if the uses a .It is possible to create a from , which is recommended for consistency in
apps. They also provide a and a key shortcut.
GLib.Property("use-stock")PropertySystem.BooleanIndicates if a mnemonic is associated with the .Gets a value indicating if the uses underline
or not.GLib.Property("use-underline")PropertyGtk.ReliefStyleThe for the .An instance of that
represents the relief style of the .GLib.Property("relief")PropertySystem.StringThe text of the in the .The contained by the .If you want the Label to have a mnemonic you need to set to .GLib.Property("label")EventSystem.EventHandler
Event launched when the is activated.GLib.Signal("activate")EventSystem.EventHandler
Event launched when the is clicked.GLib.Signal("clicked")EventSystem.EventHandler
Event launched when the cursor leaves the area.GLib.Signal("leave")EventSystem.EventHandler
Event launched when the is pressed.GLib.Signal("pressed")EventSystem.EventHandler
Event launched when the is released.GLib.Signal("released")EventSystem.EventHandler
Event launched when the cursor enters the area.GLib.Signal("enter")MethodGtk.ButtonCreates a widget with a child containing the given text.
The text you want the to hold.
The newly created widget.MethodSystem.VoidEmits a signal to the given .Emits a signal to the given .MethodSystem.VoidEmits a signal to the given .Emits a signal to the given .MethodSystem.VoidEmits a signal to the given .Emits a signal to the given .MethodSystem.VoidEmits a signal to the given .Emits a signal to the given .MethodSystem.VoidEmits a signal to the given .Emits a signal to the given .ConstructorDefault parameterless constructor.This is the default constructor for the class.ConstructorInternal constructor
an object of type This is not typically used by C# code.PropertySystem.BooleanWhether or not the cursor is inside the button.a , true if the cursor is inside the button.MethodGtk.ButtonCreates a labeled .
a a Constructor that creates a labeled . The label
shows the string passed as parameter.ConstructorCreates a new containing the image and text from a stock item.
a The valid names of Stock items can be found in the class. If is unknown, then it will be treated as a simple label.
This for example creates a stock OK button. It sets a localized label, a standard icon (choosed from your GTK theme), and the appropriate keyboard accelerator:
Button b = new Button (Stock.Ok);
PropertyGLib.GTypeGType Property.a Returns the native value for .MethodGLib.GTypeReturns the kind of action this button does.a There are four possible options: "ignored", "selects", "drags",
and "expands".MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.ConstructorProtected Constructor.
a Chain to this constructor if you have manually registered a native value for your subclass.System.ObsoleteConstructorConstructs a button containing a specified Child widget.
a child PropertySystem.Boolean
Whether the button grabs focus when it is clicked with the mouse.
a GLib.Property("focus-on-click")PropertySystem.Single
If the child of the button is a
or , this property
can be used to control its horizontal alignment.
a ;
0.0 is left aligned, 1.0 is right aligned.
GLib.Property("xalign")PropertySystem.Single
If the child of the button is a
or , this property
can be used to control its vertical alignment.
a ;
0.0 is top aligned, 1.0 is bottom aligned.
GLib.Property("yalign")MethodSystem.VoidGets the alignment of the child in the button.
a to put the horizontal alignment in
a to put the vertical alignment in
A convenience method; shouldn't be MethodSystem.Void
Sets the alignment of the child.
a ,
the horizontal position of the child; 0.0 is left aligned,
1.0 is right aligned.
a ,
the vertical position of the child; 0.0 is top aligned,
1.0 is bottom aligned.
This has no effect
unless the button's child is a
or .
PropertyGtk.WidgetChild widget to appear next to the button text.A .GLib.Property("image")PropertyGLib.Property("image-position")Gtk.PositionTypePosition of the image relative to the text.a .