Skip to content

Commit

Permalink
feat(textblock): [WASM] Added support for IsTextSelectionEnabled on T…
Browse files Browse the repository at this point in the history
…extBlock.
  • Loading branch information
carldebilly committed Jul 9, 2020
1 parent 7bac999 commit 8ad9560
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 120 deletions.
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\TextBlockControl\TextBlock_IsTextSelectionEnabled.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\TextBlockControl\TextBlock_Layout.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -3875,6 +3879,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\TextBlockControl\TextBlock_HorizontalTextAlignment.xaml.cs">
<DependentUpon>TextBlock_HorizontalTextAlignment.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\TextBlockControl\TextBlock_IsTextSelectionEnabled.xaml.cs">
<DependentUpon>TextBlock_IsTextSelectionEnabled.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\TextBlockControl\TextBlock_Layout.xaml.cs">
<DependentUpon>TextBlock_Layout.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Page
x:Class="UITests.Windows_UI_Xaml_Controls.TextBlockControl.TextBlock_IsTextSelectionEnabled"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<StackPanel Spacing="15" Margin="10">
<TextBlock FontSize="15">Following TextBlock with IsTextSelectionEnabled=false:</TextBlock>
<TextBlock FontSize="22" Foreground="Chocolate" IsTextSelectionEnabled="false">Try to select this.</TextBlock>

<TextBlock FontSize="15">Following TextBlock with IsTextSelectionEnabled=True:</TextBlock>
<TextBlock FontSize="22" Foreground="Chocolate" IsTextSelectionEnabled="true">Try to select this.</TextBlock>

<TextBlock FontSize="15">Following TextBlock with dynamic: (Default to disabled)</TextBlock>
<ToggleButton x:Name="isSelectionEnabled1">IsTextSelectionEnabled</ToggleButton>
<TextBlock FontSize="22" Foreground="Chocolate" IsTextSelectionEnabled="{Binding IsChecked, ElementName=isSelectionEnabled1}">Try to select this.</TextBlock>

<TextBlock FontSize="15">Following TextBlock with dynamic: (Default to enabled)</TextBlock>
<ToggleButton x:Name="isSelectionEnabled2" IsChecked="True">IsTextSelectionEnabled</ToggleButton>
<TextBlock FontSize="22" Foreground="Chocolate" IsTextSelectionEnabled="{Binding IsChecked, ElementName=isSelectionEnabled2}">Try to select this.</TextBlock>
</StackPanel>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Windows.UI.Xaml.Controls;
using Uno.UI.Samples.Controls;

namespace UITests.Windows_UI_Xaml_Controls.TextBlockControl
{
[Sample]
public sealed partial class TextBlock_IsTextSelectionEnabled : Page
{
public TextBlock_IsTextSelectionEnabled()
{
this.InitializeComponent();
}
}
}
7 changes: 5 additions & 2 deletions src/Uno.UI.Wasm/WasmCSS/Uno.UI.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,17 @@ embed.uno-frameworkelement.uno-unarranged {
height: 0;
}

.uno-textblock {
text-rendering: optimizeLegibility; /* iOS Safari */
.uno-textblock:not(.selectionEnabled) {
-webkit-touch-callout: none; /* Safari */
-webkit-user-select: none; /* iOSSafari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */
}

.uno-textblock {
text-rendering: optimizeLegibility; /* iOS Safari */

/* Following are required for gradient brush as Foreground on text. Should not affect normal rendering. */
-ms-background-clip: text !important;
Expand Down
32 changes: 6 additions & 26 deletions src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/TextBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,14 @@ public partial class TextBlock
this.SetValue(FontStretchProperty, value);
}
}
#endif
#endif
// Skipping already declared property FontSize
// Skipping already declared property FontFamily
// Skipping already declared property LineStackingStrategy
// Skipping already declared property LineHeight
// Skipping already declared property CharacterSpacing
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
[global::Uno.NotImplemented]
public bool IsTextSelectionEnabled
{
get
{
return (bool)this.GetValue(IsTextSelectionEnabledProperty);
}
set
{
this.SetValue(IsTextSelectionEnabledProperty, value);
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
// Skipping already declared property IsTextSelectionEnabled
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
[global::Uno.NotImplemented]
public string SelectedText
{
Expand Down Expand Up @@ -240,22 +227,15 @@ public bool IsTextTrimmed
nameof(FontStretch), typeof(global::Windows.UI.Text.FontStretch),
typeof(global::Windows.UI.Xaml.Controls.TextBlock),
new FrameworkPropertyMetadata(default(global::Windows.UI.Text.FontStretch)));
#endif
#endif
// Skipping already declared property FontStyleProperty
// Skipping already declared property FontWeightProperty
// Skipping already declared property ForegroundProperty
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
[global::Uno.NotImplemented]
public static global::Windows.UI.Xaml.DependencyProperty IsTextSelectionEnabledProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
nameof(IsTextSelectionEnabled), typeof(bool),
typeof(global::Windows.UI.Xaml.Controls.TextBlock),
new FrameworkPropertyMetadata(default(bool)));
#endif
// Skipping already declared property IsTextSelectionEnabledProperty
// Skipping already declared property LineHeightProperty
// Skipping already declared property LineStackingStrategyProperty
// Skipping already declared property PaddingProperty
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
[global::Uno.NotImplemented]
public static global::Windows.UI.Xaml.DependencyProperty SelectedTextProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
Expand Down
Loading

0 comments on commit 8ad9560

Please sign in to comment.