Table of Contents

Class Button

Namespace
Myra.Graphics2D.UI
Assembly
Myra.dll

A clickable button widget that can contain any widget as its content.

public class Button : ButtonBase, IItemWithId, INotifyAttachedPropertyChanged, IContent
Inheritance
Button
Implements
Inherited Members

Constructors

Button(Stylesheet, string)

Initializes a new instance of the Button class with the specified stylesheet and style.

public Button(Stylesheet stylesheet, string styleName = "")

Parameters

stylesheet Stylesheet

The stylesheet to use for applying the style.

styleName string

The name of the style to apply. Defaults to the default stylesheet style.

Button(string)

Initializes a new instance of the Button class with the specified style.

public Button(string styleName = "")

Parameters

styleName string

The name of the style to apply. Defaults to the default stylesheet style.

Properties

Content

Gets or sets the content widget displayed inside the button.

[Browsable(false)]
public override Widget Content { get; set; }

Property Value

Widget

Desktop

Gets or sets the desktop that contains this button.

public override Desktop Desktop { get; }

Property Value

Desktop

Methods

CreateTextButton(string)

Creates a button with a text label as its content.

public static Button CreateTextButton(string text)

Parameters

text string

The text to display on the button.

Returns

Button

A new Button with a text label.

InternalOnTouchDown()

Called when a touch point is pressed on the button.

protected override void InternalOnTouchDown()

InternalOnTouchUp()

Called when a touch point is released on the button.

protected override void InternalOnTouchUp()

OnKeyDown(Keys)

Handles keyboard input for the button, simulating a click when Space is pressed.

public override void OnKeyDown(Keys k)

Parameters

k Keys

The key being pressed.

OnTouchLeft()

Handles the event when the cursor/touch leaves the button.

public override void OnTouchLeft()