mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Grouping views events in the ViewEventArgs.cs file.
This commit is contained in:
@@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Terminal.Gui {
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Defines the event arguments for <see cref="View.SetFocus(View)"/>
|
|
||||||
/// </summary>
|
|
||||||
public class FocusEventArgs : EventArgs {
|
|
||||||
/// <summary>
|
|
||||||
/// Constructs.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="view">The view that gets or loses focus.</param>
|
|
||||||
public FocusEventArgs (View view) { View = view; }
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates if the current focus event has already been processed and the driver should stop notifying any other event subscriber.
|
|
||||||
/// Its important to set this value to true specially when updating any View's layout from inside the subscriber method.
|
|
||||||
/// </summary>
|
|
||||||
public bool Handled { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates the current view that gets or loses focus.
|
|
||||||
/// </summary>
|
|
||||||
public View View { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -139,17 +139,17 @@ namespace Terminal.Gui {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event fired when the view receives the mouse event for the first time.
|
/// Event fired when the view receives the mouse event for the first time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<MouseEventArgs> MouseEnter;
|
public event EventHandler<MouseEventEventArgs> MouseEnter;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event fired when the view receives a mouse event for the last time.
|
/// Event fired when the view receives a mouse event for the last time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<MouseEventArgs> MouseLeave;
|
public event EventHandler<MouseEventEventArgs> MouseLeave;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event fired when a mouse event is generated.
|
/// Event fired when a mouse event is generated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<MouseEventArgs> MouseClick;
|
public event EventHandler<MouseEventEventArgs> MouseClick;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event fired when the <see cref="CanFocus"/> value is being changed.
|
/// Event fired when the <see cref="CanFocus"/> value is being changed.
|
||||||
@@ -827,7 +827,7 @@ namespace Terminal.Gui {
|
|||||||
|
|
||||||
void TextFormatter_HotKeyChanged (object sender, KeyChangedEventArgs e)
|
void TextFormatter_HotKeyChanged (object sender, KeyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
HotKeyChanged?.Invoke (this,e);
|
HotKeyChanged?.Invoke (this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -942,7 +942,7 @@ namespace Terminal.Gui {
|
|||||||
}
|
}
|
||||||
SetNeedsLayout ();
|
SetNeedsLayout ();
|
||||||
SetNeedsDisplay ();
|
SetNeedsDisplay ();
|
||||||
OnAdded (new SuperViewChangedEventArgs (this,view));
|
OnAdded (new SuperViewChangedEventArgs (this, view));
|
||||||
if (IsInitialized) {
|
if (IsInitialized) {
|
||||||
view.BeginInit ();
|
view.BeginInit ();
|
||||||
view.EndInit ();
|
view.EndInit ();
|
||||||
@@ -1344,7 +1344,7 @@ namespace Terminal.Gui {
|
|||||||
view.width ??= view.frame.Width;
|
view.width ??= view.frame.Width;
|
||||||
view.height ??= view.frame.Height;
|
view.height ??= view.frame.Height;
|
||||||
|
|
||||||
view.Added?.Invoke (this,e);
|
view.Added?.Invoke (this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1593,7 +1593,7 @@ namespace Terminal.Gui {
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public virtual void OnDrawContent (Rect viewport)
|
public virtual void OnDrawContent (Rect viewport)
|
||||||
{
|
{
|
||||||
DrawContent?.Invoke (this, new DrawEventArgs(viewport));
|
DrawContent?.Invoke (this, new DrawEventArgs (viewport));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -2239,16 +2239,6 @@ namespace Terminal.Gui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event arguments for the <see cref="LayoutComplete"/> event.
|
|
||||||
/// </summary>
|
|
||||||
public class LayoutEventArgs : EventArgs {
|
|
||||||
/// <summary>
|
|
||||||
/// The view-relative bounds of the <see cref="View"/> before it was laid out.
|
|
||||||
/// </summary>
|
|
||||||
public Rect OldBounds { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired after the View's <see cref="LayoutSubviews"/> method has completed.
|
/// Fired after the View's <see cref="LayoutSubviews"/> method has completed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -2795,34 +2785,6 @@ namespace Terminal.Gui {
|
|||||||
frame.Size.Height + GetHotKeySpecifierLength (false));
|
frame.Size.Height + GetHotKeySpecifierLength (false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Specifies the event arguments for <see cref="MouseEvent"/>. This is a higher-level construct
|
|
||||||
/// than the wrapped <see cref="MouseEvent"/> class and is used for the events defined on <see cref="View"/>
|
|
||||||
/// and subclasses of View (e.g. <see cref="View.MouseEnter"/> and <see cref="View.MouseClick"/>).
|
|
||||||
/// </summary>
|
|
||||||
public class MouseEventArgs : EventArgs {
|
|
||||||
/// <summary>
|
|
||||||
/// Constructs.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="me"></param>
|
|
||||||
public MouseEventArgs (MouseEvent me) => MouseEvent = me;
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="MouseEvent"/> for the event.
|
|
||||||
/// </summary>
|
|
||||||
public MouseEvent MouseEvent { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates if the current mouse event has already been processed and the driver should stop notifying any other event subscriber.
|
|
||||||
/// Its important to set this value to true specially when updating any View's layout from inside the subscriber method.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>This property forwards to the <see cref="MouseEvent.Handled"/> property and is provided as a convenience and for
|
|
||||||
/// backwards compatibility</remarks>
|
|
||||||
public bool Handled {
|
|
||||||
get => MouseEvent.Handled;
|
|
||||||
set => MouseEvent.Handled = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool OnMouseEnter (MouseEvent mouseEvent)
|
public override bool OnMouseEnter (MouseEvent mouseEvent)
|
||||||
{
|
{
|
||||||
@@ -2834,7 +2796,7 @@ namespace Terminal.Gui {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = new MouseEventArgs (mouseEvent);
|
var args = new MouseEventEventArgs (mouseEvent);
|
||||||
MouseEnter?.Invoke (this, args);
|
MouseEnter?.Invoke (this, args);
|
||||||
|
|
||||||
return args.Handled || base.OnMouseEnter (mouseEvent);
|
return args.Handled || base.OnMouseEnter (mouseEvent);
|
||||||
@@ -2851,7 +2813,7 @@ namespace Terminal.Gui {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = new MouseEventArgs (mouseEvent);
|
var args = new MouseEventEventArgs (mouseEvent);
|
||||||
MouseLeave?.Invoke (this, args);
|
MouseLeave?.Invoke (this, args);
|
||||||
|
|
||||||
return args.Handled || base.OnMouseLeave (mouseEvent);
|
return args.Handled || base.OnMouseLeave (mouseEvent);
|
||||||
@@ -2872,7 +2834,7 @@ namespace Terminal.Gui {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = new MouseEventArgs (mouseEvent);
|
var args = new MouseEventEventArgs (mouseEvent);
|
||||||
if (OnMouseClick (args))
|
if (OnMouseClick (args))
|
||||||
return true;
|
return true;
|
||||||
if (MouseEvent (mouseEvent))
|
if (MouseEvent (mouseEvent))
|
||||||
@@ -2892,7 +2854,7 @@ namespace Terminal.Gui {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invokes the MouseClick event.
|
/// Invokes the MouseClick event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected bool OnMouseClick (MouseEventArgs args)
|
protected bool OnMouseClick (MouseEventEventArgs args)
|
||||||
{
|
{
|
||||||
if (!Enabled) {
|
if (!Enabled) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Terminal.Gui {
|
namespace Terminal.Gui {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Args for events that relate to specific <see cref="View"/>
|
/// Args for events that relate to specific <see cref="View"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ViewEventArgs :EventArgs{
|
public class ViewEventArgs : EventArgs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the <see cref="ViewEventArgs"/> class.
|
/// Creates a new instance of the <see cref="Terminal.Gui.View"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="view"></param>
|
/// <param name="view"></param>
|
||||||
public ViewEventArgs (View view)
|
public ViewEventArgs (View view)
|
||||||
@@ -30,4 +26,55 @@ namespace Terminal.Gui {
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public View View { get; }
|
public View View { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event arguments for the <see cref="View.LayoutComplete"/> event.
|
||||||
|
/// </summary>
|
||||||
|
public class LayoutEventArgs : EventArgs {
|
||||||
|
/// <summary>
|
||||||
|
/// The view-relative bounds of the <see cref="View"/> before it was laid out.
|
||||||
|
/// </summary>
|
||||||
|
public Rect OldBounds { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event args for draw events
|
||||||
|
/// </summary>
|
||||||
|
public class DrawEventArgs : EventArgs {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the <see cref="DrawEventArgs"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rect">Gets the view-relative rectangle describing the currently visible viewport into the <see cref="View"/>.</param>
|
||||||
|
public DrawEventArgs (Rect rect)
|
||||||
|
{
|
||||||
|
Rect = rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the view-relative rectangle describing the currently visible viewport into the <see cref="View"/>.
|
||||||
|
/// </summary>
|
||||||
|
public Rect Rect { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the event arguments for <see cref="View.SetFocus(View)"/>
|
||||||
|
/// </summary>
|
||||||
|
public class FocusEventArgs : EventArgs {
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="view">The view that gets or loses focus.</param>
|
||||||
|
public FocusEventArgs (View view) { View = view; }
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if the current focus event has already been processed and the driver should stop notifying any other event subscriber.
|
||||||
|
/// Its important to set this value to true specially when updating any View's layout from inside the subscriber method.
|
||||||
|
/// </summary>
|
||||||
|
public bool Handled { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates the current view that gets or loses focus.
|
||||||
|
/// </summary>
|
||||||
|
public View View { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Terminal.Gui {
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event args for draw events
|
|
||||||
/// </summary>
|
|
||||||
public class DrawEventArgs : EventArgs{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new instance of the <see cref="DrawEventArgs"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rect">Gets the view-relative rectangle describing the currently visible viewport into the <see cref="View"/>.</param>
|
|
||||||
public DrawEventArgs (Rect rect)
|
|
||||||
{
|
|
||||||
Rect = rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the view-relative rectangle describing the currently visible viewport into the <see cref="View"/>.
|
|
||||||
/// </summary>
|
|
||||||
public Rect Rect { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user