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: Add IsPointerCaptureRequired attached property
- Loading branch information
1 parent
4874eb9
commit 85abb78
Showing
2 changed files
with
56 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Microsoft.UI.Xaml; | ||
|
||
namespace Uno.UI.Xaml.Controls; | ||
|
||
/// <summary> | ||
/// Contains additional attached properties that provide Uno-specific | ||
/// behavior for TextBox control. | ||
/// </summary> | ||
public class TextBox | ||
{ | ||
#if __CROSSRUNTIME__ | ||
/// <summary> | ||
/// Gets the value indicating whether the pointer capture on pointer press should be required. | ||
/// </summary> | ||
/// <remarks> | ||
/// This flag is only applied in case of WebAssembly. | ||
/// </remarks> | ||
/// <param name="textBox">TextBox.</param> | ||
/// <returns>Value.</returns> | ||
public static bool GetIsPointerCaptureRequired(Microsoft.UI.Xaml.Controls.TextBox textBox) => | ||
(bool)textBox.GetValue(IsPointerCaptureRequiredProperty); | ||
|
||
/// <summary> | ||
/// Sets the value indicating whether the pointer capture on pointer press should be required. | ||
/// </summary> | ||
/// <remarks> | ||
/// This flag is only applied in case of WebAssembly. | ||
/// </remarks> | ||
/// <param name="textBox">TextBox.</param> | ||
/// <param name="value">Value.</param> | ||
public static void SetIsPointerCaptureRequired(Microsoft.UI.Xaml.Controls.TextBox textBox, bool value) => | ||
textBox.SetValue(IsPointerCaptureRequiredProperty, value); | ||
|
||
/// <summary> | ||
/// Identifies the IsPointerCaptureRequired attached property. | ||
/// </summary> | ||
public static DependencyProperty IsPointerCaptureRequiredProperty { get; } = | ||
DependencyProperty.RegisterAttached( | ||
"IsPointerCaptureRequired", | ||
typeof(bool), | ||
typeof(TextBox), | ||
new FrameworkPropertyMetadata( | ||
// We should not capture the pointer on WASM by default because it would prevent the user from scrolling through text on selection. | ||
// See https://github.com/unoplatform/uno/pull/16982, https://issues.chromium.org/issues/344491566 | ||
false)); | ||
#endif | ||
} |
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