using System.ComponentModel;
namespace Terminal.Gui.App;
public static partial class Application // Mouse handling
{
private static bool _isMouseDisabled = false; // Resources/config.json overrides
/// Disable or enable the mouse. The mouse is enabled by default.
[ConfigurationProperty (Scope = typeof (SettingsScope))]
[Obsolete ("The legacy static Application object is going away.")]
public static bool IsMouseDisabled
{
get => _isMouseDisabled;
set
{
bool oldValue = _isMouseDisabled;
_isMouseDisabled = value;
IsMouseDisabledChanged?.Invoke (null, new ValueChangedEventArgs (oldValue, _isMouseDisabled));
}
}
/// Raised when changes.
public static event EventHandler>? IsMouseDisabledChanged;
///
/// Gets the instance that manages mouse event handling and state.
///
///
///
/// This property provides access to mouse-related functionality in a way that supports
/// parallel test execution by avoiding static state.
///
///
[Obsolete ("The legacy static Application object is going away.")]
public static IMouse Mouse => ApplicationImpl.Instance.Mouse;
#pragma warning disable CS1574 // XML comment has cref attribute that could not be resolved
///
/// Raised when a mouse event occurs. Can be cancelled by setting to
/// .
///
///
///
/// coordinates are screen-relative.
///
///
/// will be the deepest view under the mouse.
///
///
/// coordinates are view-relative. Only valid if
/// is set.
///
///
/// Use this even to handle mouse events at the application level, before View-specific handling.
///
///
[Obsolete ("The legacy static Application object is going away.")]
public static event EventHandler? MouseEvent
{
add => Mouse.MouseEvent += value;
remove => Mouse.MouseEvent -= value;
}
#pragma warning restore CS1574 // XML comment has cref attribute that could not be resolved
///
/// INTERNAL: Holds the non- views that are currently under the
/// mouse.
///
[Obsolete ("The legacy static Application object is going away.")]
internal static List CachedViewsUnderMouse => Mouse.CachedViewsUnderMouse;
///
/// INTERNAL API: Holds the last mouse position.
///
[Obsolete ("The legacy static Application object is going away.")]
internal static Point? LastMousePosition
{
get => Mouse.LastMousePosition;
set => Mouse.LastMousePosition = value;
}
///
/// INTERNAL: Raises the MouseEnter and MouseLeave events for the views that are under the mouse.
///
/// The position of the mouse.
/// The most recent result from GetViewsUnderLocation().
[Obsolete ("The legacy static Application object is going away.")]
internal static void RaiseMouseEnterLeaveEvents (Point screenPosition, List currentViewsUnderMouse)
{
Mouse.RaiseMouseEnterLeaveEvents (screenPosition, currentViewsUnderMouse);
}
///
/// INTERNAL API: Called when a mouse event is raised by the driver. Determines the view under the mouse and
/// calls the appropriate View mouse event handlers.
///
/// This method can be used to simulate a mouse event, e.g. in unit tests.
/// The mouse event with coordinates relative to the screen.
[Obsolete ("The legacy static Application object is going away.")]
internal static void RaiseMouseEvent (MouseEventArgs mouseEvent)
{
Mouse.RaiseMouseEvent (mouseEvent);
}
}