This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efb2812
commit 507eb74
Showing
21 changed files
with
1,163 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/Avalonia.Xaml.Interactions/Events/DoubleTappedEventBehavior.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,57 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Input; | ||
using Avalonia.Interactivity; | ||
using Avalonia.Xaml.Interactivity; | ||
|
||
namespace Avalonia.Xaml.Interactions.Events; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class DoubleTappedEventBehavior<T> : Behavior<T> where T : Control | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static readonly StyledProperty<RoutingStrategies> RoutingStrategiesProperty = | ||
AvaloniaProperty.Register<DoubleTappedEventBehavior<T>, RoutingStrategies>( | ||
nameof(RoutingStrategies), | ||
RoutingStrategies.Bubble); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public RoutingStrategies RoutingStrategies | ||
{ | ||
get => GetValue(RoutingStrategiesProperty); | ||
set => SetValue(RoutingStrategiesProperty, value); | ||
} | ||
|
||
|
||
/// <inheritdoc /> | ||
protected override void OnAttachedToVisualTree() | ||
{ | ||
AssociatedObject?.AddHandler(Gestures.DoubleTappedEvent, DoubleTapped, RoutingStrategies); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnDetachedFromVisualTree() | ||
{ | ||
AssociatedObject?.RemoveHandler(Gestures.DoubleTappedEvent, DoubleTapped); | ||
} | ||
|
||
private void DoubleTapped(object? sender, RoutedEventArgs e) | ||
{ | ||
OnDoubleTapped(sender, e); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
protected virtual void OnDoubleTapped(object? sender, RoutedEventArgs e) | ||
{ | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/Avalonia.Xaml.Interactions/Events/GotFocusEventBehavior.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,57 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Input; | ||
using Avalonia.Interactivity; | ||
using Avalonia.Xaml.Interactivity; | ||
|
||
namespace Avalonia.Xaml.Interactions.Events; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class GotFocusEventBehavior<T> : Behavior<T> where T : Control | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static readonly StyledProperty<RoutingStrategies> RoutingStrategiesProperty = | ||
AvaloniaProperty.Register<GotFocusEventBehavior<T>, RoutingStrategies>( | ||
nameof(RoutingStrategies), | ||
RoutingStrategies.Bubble); | ||
|
||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public RoutingStrategies RoutingStrategies | ||
{ | ||
get => GetValue(RoutingStrategiesProperty); | ||
set => SetValue(RoutingStrategiesProperty, value); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnAttachedToVisualTree() | ||
{ | ||
AssociatedObject?.AddHandler(InputElement.GotFocusEvent, GotFocus, RoutingStrategies); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnDetachedFromVisualTree() | ||
{ | ||
AssociatedObject?.RemoveHandler(InputElement.GotFocusEvent, GotFocus); | ||
} | ||
|
||
private void GotFocus(object? sender, GotFocusEventArgs e) | ||
{ | ||
OnGotFocus(sender, e); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
protected virtual void OnGotFocus(object? sender, GotFocusEventArgs e) | ||
{ | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/Avalonia.Xaml.Interactions/Events/KeyDownEventBehavior.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,56 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Input; | ||
using Avalonia.Interactivity; | ||
using Avalonia.Xaml.Interactivity; | ||
|
||
namespace Avalonia.Xaml.Interactions.Events; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class KeyDownEventBehavior<T> : Behavior<T> where T : Control | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static readonly StyledProperty<RoutingStrategies> RoutingStrategiesProperty = | ||
AvaloniaProperty.Register<KeyDownEventBehavior<T>, RoutingStrategies>( | ||
nameof(RoutingStrategies), | ||
RoutingStrategies.Tunnel | RoutingStrategies.Bubble); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public RoutingStrategies RoutingStrategies | ||
{ | ||
get => GetValue(RoutingStrategiesProperty); | ||
set => SetValue(RoutingStrategiesProperty, value); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnAttachedToVisualTree() | ||
{ | ||
AssociatedObject?.AddHandler(InputElement.KeyDownEvent, KeyDown, RoutingStrategies); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnDetachedFromVisualTree() | ||
{ | ||
AssociatedObject?.RemoveHandler(InputElement.KeyDownEvent, KeyDown); | ||
} | ||
|
||
private void KeyDown(object? sender, KeyEventArgs e) | ||
{ | ||
OnKeyDown(sender, e); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
protected virtual void OnKeyDown(object? sender, KeyEventArgs e) | ||
{ | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/Avalonia.Xaml.Interactions/Events/KeyUpEventBehavior.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,56 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Input; | ||
using Avalonia.Interactivity; | ||
using Avalonia.Xaml.Interactivity; | ||
|
||
namespace Avalonia.Xaml.Interactions.Events; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class KeyUpEventBehavior<T> : Behavior<T> where T : Control | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static readonly StyledProperty<RoutingStrategies> RoutingStrategiesProperty = | ||
AvaloniaProperty.Register<KeyUpEventBehavior<T>, RoutingStrategies>( | ||
nameof(RoutingStrategies), | ||
RoutingStrategies.Tunnel | RoutingStrategies.Bubble); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public RoutingStrategies RoutingStrategies | ||
{ | ||
get => GetValue(RoutingStrategiesProperty); | ||
set => SetValue(RoutingStrategiesProperty, value); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnAttachedToVisualTree() | ||
{ | ||
AssociatedObject?.AddHandler(InputElement.KeyUpEvent, KeyUp, RoutingStrategies); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnDetachedFromVisualTree() | ||
{ | ||
AssociatedObject?.RemoveHandler(InputElement.KeyUpEvent, KeyUp); | ||
} | ||
|
||
private void KeyUp(object? sender, KeyEventArgs e) | ||
{ | ||
OnKeyUp(sender, e); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
protected virtual void OnKeyUp(object? sender, KeyEventArgs e) | ||
{ | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/Avalonia.Xaml.Interactions/Events/LostFocusEventBehavior.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,56 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Input; | ||
using Avalonia.Interactivity; | ||
using Avalonia.Xaml.Interactivity; | ||
|
||
namespace Avalonia.Xaml.Interactions.Events; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class LostFocusEventBehavior<T> : Behavior<T> where T : Control | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static readonly StyledProperty<RoutingStrategies> RoutingStrategiesProperty = | ||
AvaloniaProperty.Register<LostFocusEventBehavior<T>, RoutingStrategies>( | ||
nameof(RoutingStrategies), | ||
RoutingStrategies.Bubble); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public RoutingStrategies RoutingStrategies | ||
{ | ||
get => GetValue(RoutingStrategiesProperty); | ||
set => SetValue(RoutingStrategiesProperty, value); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnAttachedToVisualTree() | ||
{ | ||
AssociatedObject?.AddHandler(InputElement.LostFocusEvent, LostFocus, RoutingStrategies); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnDetachedFromVisualTree() | ||
{ | ||
AssociatedObject?.RemoveHandler(InputElement.LostFocusEvent, LostFocus); | ||
} | ||
|
||
private void LostFocus(object? sender, RoutedEventArgs e) | ||
{ | ||
OnLostFocus(sender, e); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
protected virtual void OnLostFocus(object? sender, RoutedEventArgs e) | ||
{ | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/Avalonia.Xaml.Interactions/Events/PointerCaptureLostEventBehavior.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,56 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Input; | ||
using Avalonia.Interactivity; | ||
using Avalonia.Xaml.Interactivity; | ||
|
||
namespace Avalonia.Xaml.Interactions.Events; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class PointerCaptureLostEventBehavior<T> : Behavior<T> where T : Control | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static readonly StyledProperty<RoutingStrategies> RoutingStrategiesProperty = | ||
AvaloniaProperty.Register<PointerCaptureLostEventBehavior<T>, RoutingStrategies>( | ||
nameof(RoutingStrategies), | ||
RoutingStrategies.Direct); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public RoutingStrategies RoutingStrategies | ||
{ | ||
get => GetValue(RoutingStrategiesProperty); | ||
set => SetValue(RoutingStrategiesProperty, value); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnAttachedToVisualTree() | ||
{ | ||
AssociatedObject?.AddHandler(InputElement.PointerCaptureLostEvent, PointerCaptureLost, RoutingStrategies); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnDetachedFromVisualTree() | ||
{ | ||
AssociatedObject?.RemoveHandler(InputElement.PointerCaptureLostEvent, PointerCaptureLost); | ||
} | ||
|
||
private void PointerCaptureLost(object? sender, PointerCaptureLostEventArgs e) | ||
{ | ||
OnPointerCaptureLost(sender, e); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
protected virtual void OnPointerCaptureLost(object? sender, PointerCaptureLostEventArgs e) | ||
{ | ||
} | ||
} |
Oops, something went wrong.