forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement new focus-related types
- Loading branch information
1 parent
49b637f
commit ed17993
Showing
9 changed files
with
191 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Microsoft.UI.Input; | ||
|
||
/// <summary> | ||
/// Contains event data for the InputFocusController.GotFocus and InputFocusController.LostFocus events. | ||
/// </summary> | ||
public partial class FocusChangedEventArgs | ||
{ | ||
internal FocusChangedEventArgs() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets whether the InputFocusController.GotFocus and InputFocusController.LostFocus events were handled. | ||
/// </summary> | ||
public bool Handled { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// <auto-generated> | ||
#pragma warning disable 108 // new keyword hiding | ||
namespace Microsoft.UI.Input; | ||
|
||
/// <summary> | ||
/// Specifies the possible reasons for a focus navigation event. | ||
/// </summary> | ||
public enum FocusNavigationReason | ||
{ | ||
/// <summary> | ||
/// Programmatically perform focus navigation. | ||
/// </summary> | ||
Programmatic = 0, | ||
|
||
/// <summary> | ||
/// Restore focus to a previous state. | ||
/// </summary> | ||
Restore = 1, | ||
|
||
/// <summary> | ||
/// Navigate to the first element in the focus recipient. | ||
/// </summary> | ||
First = 2, | ||
|
||
/// <summary> | ||
/// Navigate to the last element in the focus recipient. | ||
/// </summary> | ||
Last = 3, | ||
|
||
/// <summary> | ||
/// Navigate focus left. | ||
/// </summary> | ||
Left = 4, | ||
|
||
/// <summary> | ||
/// Navigate focus up. | ||
/// </summary> | ||
Up = 5, | ||
|
||
/// <summary> | ||
/// Navigate focus right. | ||
/// </summary> | ||
Right = 6, | ||
|
||
/// <summary> | ||
/// Navigate focus down. | ||
/// </summary> | ||
Down = 7, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using Windows.Foundation; | ||
|
||
namespace Microsoft.UI.Input; | ||
|
||
/// <summary> | ||
/// Provides details for focus navigation events. | ||
/// </summary> | ||
public partial class FocusNavigationRequest | ||
{ | ||
internal FocusNavigationRequest(FocusNavigationReason reason) | ||
{ | ||
Reason = reason; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the unique ID generated when a focus movement event is initiated. | ||
/// </summary> | ||
public Guid CorrelationId { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the reason for a focus navigation event. | ||
/// </summary> | ||
public FocusNavigationReason Reason { get; } | ||
|
||
/// <summary> | ||
/// Gets the bounding rectangle used to identify the focus candidates most likely to receive navigation focus. | ||
/// </summary> | ||
public Rect? HintRect { get; init; } | ||
|
||
/// <summary> | ||
/// Creates an instance of FocusNavigationRequest using the specified FocusNavigationReason. | ||
/// </summary> | ||
/// <param name="reason">The reason for a focus navigation event.</param> | ||
/// <returns>A FocusNavigationRequest object.</returns> | ||
public static FocusNavigationRequest Create(FocusNavigationReason reason) => new(reason); | ||
|
||
/// <summary> | ||
/// Creates an instance of FocusNavigationRequest using the specified FocusNavigationReason and hint Rect. | ||
/// </summary> | ||
/// <param name="reason">The reason for a focus navigation event.</param> | ||
/// <param name="hintRect">The bounding rectangle used to identify the focus candidates most likely to receive navigation focus.</param> | ||
/// <returns>A FocusNavigationRequest object.</returns> | ||
public static FocusNavigationRequest Create(FocusNavigationReason reason, Rect hintRect) => new(reason) | ||
{ | ||
HintRect = hintRect | ||
}; | ||
|
||
/// <summary> | ||
/// Creates an instance of FocusNavigationRequest using the specified FocusNavigationReason, hint Rect, and unique identifier. | ||
/// </summary> | ||
/// <param name="reason">The reason for a focus navigation event.</param> | ||
/// <param name="hintRect">The bounding rectangle used to identify the focus candidates most likely to receive navigation focus.</param> | ||
/// <param name="correlationId">The unique ID generated when a focus movement event is initiated.</param> | ||
/// <returns>A FocusNavigationRequest object.</returns> | ||
public static FocusNavigationRequest Create(FocusNavigationReason reason, Rect hintRect, Guid correlationId) => new(reason) | ||
{ | ||
HintRect = hintRect, | ||
CorrelationId = correlationId | ||
}; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Uno.UI/Microsoft/UI/Input/FocusNavigationRequestEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
|
||
namespace Microsoft.UI.Input; | ||
|
||
/// <summary> | ||
/// Contains event data for the InputFocusController.NavigateFocusRequested and InputFocusNavigationHost.DepartFocusRequested events. | ||
/// </summary> | ||
public partial class FocusNavigationRequestEventArgs | ||
{ | ||
internal FocusNavigationRequestEventArgs(FocusNavigationRequest request) | ||
{ | ||
Request = request ?? throw new ArgumentNullException(nameof(request)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the details for focus navigation event. | ||
/// </summary> | ||
public FocusNavigationRequest Request { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets the result of a focus navigation event. | ||
/// </summary> | ||
public FocusNavigationResult Result { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Microsoft.UI.Input; | ||
|
||
/// <summary> | ||
/// Specifies the possible results of a focus navigation event. | ||
/// </summary> | ||
public enum FocusNavigationResult | ||
{ | ||
/// <summary> | ||
/// Event was not subscribed or the event ran into an error. This is the default value. | ||
/// </summary> | ||
NotMoved = 0, | ||
|
||
/// <summary> | ||
/// Focus successfully moved to another component. | ||
/// </summary> | ||
Moved = 1, | ||
|
||
/// <summary> | ||
/// No focusable element was found. | ||
/// </summary> | ||
NoFocusableElements = 2, | ||
} |