namespace Terminal.Gui; /// /// objects are contained by s. Each /// has a title, a shortcut (hotkey), and an that will be invoked when /// the is pressed. The will be a global hotkey for /// the application in the current context of the screen. The color of the will be /// changed after each ~. A set to `~F1~ Help` will render as *F1* using /// and *Help* as . /// public class StatusItem { /// Initializes a new . /// Shortcut to activate the . /// Title for the . /// Action to invoke when the is activated. /// Function to determine if the action can currently be executed. public StatusItem (Key shortcut, string title, Action action, Func canExecute = null) { Title = title ?? ""; Shortcut = shortcut; Action = action; CanExecute = canExecute; } /// Gets or sets the action to be invoked when the is triggered /// Action to invoke. public Action Action { get; set; } /// /// Gets or sets the action to be invoked to determine if the can be triggered. If /// returns the status item will be enabled. Otherwise, it will be /// disabled. /// /// Function to determine if the action is can be executed or not. public Func CanExecute { get; set; } /// Gets or sets arbitrary data for the status item. /// This property is not used internally. public object Data { get; set; } /// Gets the global shortcut to invoke the action on the menu. public Key Shortcut { get; set; } /// Gets or sets the title. /// The title. /// /// The colour of the will be changed after each ~. A /// set to `~F1~ Help` will render as *F1* using and /// *Help* as . /// public string Title { get; set; } /// /// Returns if the status item is enabled. This method is a wrapper around /// . /// public bool IsEnabled () { return CanExecute?.Invoke () ?? true; } }