//
// Label.cs: Label control
//
// Authors:
// Miguel de Icaza (miguel@gnome.org)
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using NStack;
namespace Terminal.Gui {
///
/// The Label displays a string at a given position and supports multiple lines separted by newline characters. Multi-line Labels support word wrap.
///
///
/// The view is functionality identical to and is included for API backwards compatibility.
///
public class Label : View {
///
public Label ()
{
}
///
public Label (Rect frame) : base (frame)
{
}
///
public Label (ustring text) : base (text)
{
}
///
public Label (Rect rect, ustring text) : base (rect, text)
{
}
///
public Label (int x, int y, ustring text) : base (x, y, text)
{
}
///
/// Clicked , raised when the user clicks the primary mouse button within the Bounds of this
/// or if the user presses the action key while this view is focused. (TODO: IsDefault)
///
///
/// Client code can hook up to this event, it is
/// raised when the button is activated either with
/// the mouse or the keyboard.
///
public event Action Clicked;
/////
//public new ustring Text {
// get => base.Text;
// set {
// base.Text = value;
// // This supports Label auto-sizing when Text changes (preserving backwards compat behavior)
// if (Frame.Height == 1 && !ustring.IsNullOrEmpty (value)) {
// int w = Text.RuneCount;
// Width = w;
// Frame = new Rect (Frame.Location, new Size (w, Frame.Height));
// }
// SetNeedsDisplay ();
// }
//}
///
/// Method invoked when a mouse event is generated
///
///
/// true, if the event was handled, false otherwise.
public override bool OnMouseEvent (MouseEvent mouseEvent)
{
MouseEventArgs args = new MouseEventArgs (mouseEvent);
OnMouseClick (args);
if (args.Handled)
return true;
if (MouseEvent (mouseEvent))
return true;
if (mouseEvent.Flags == MouseFlags.Button1Clicked) {
if (!HasFocus && SuperView != null) {
SetFocus ();
SetNeedsDisplay ();
}
Clicked?.Invoke ();
return true;
}
return false;
}
}
}