Skip to content

Commit

Permalink
Fix scrolling not working when a text box is touched in a popup
Browse files Browse the repository at this point in the history
Closes #102
  • Loading branch information
rampaa committed Oct 10, 2024
1 parent 93c33f3 commit b39554b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion JL.Windows/GUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Title="JL"
AllowsTransparency="True"
mc:Ignorable="d" MinWidth="100" MinHeight="50" Width="800" Height="200" WindowStyle="None" ResizeMode="NoResize" Topmost="True"
Closing="MainWindow_Closing" PreviewKeyDown="Window_PreviewKeyDown" ScrollViewer.PanningMode="VerticalOnly"
Closing="MainWindow_Closing" PreviewKeyDown="Window_PreviewKeyDown" ScrollViewer.PanningMode="VerticalFirst"
SizeChanged="MainWindow_SizeChanged" LocationChanged="Window_LocationChanged" ShowActivated="False"
PreviewMouseDown="Window_PreviewMouseDown" DpiChanged="Window_DpiChanged" MouseLeave="Window_MouseLeave" MouseEnter="Window_MouseEnter" StateChanged="Window_StateChanged"
x:ClassModifier="internal">
Expand Down
2 changes: 1 addition & 1 deletion JL.Windows/GUI/PopupWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
VirtualizingPanel.IsVirtualizingWhenGrouping="True" VirtualizingPanel.ScrollUnit="Pixel"
BorderThickness="0" ScrollViewer.CanContentScroll="True" VirtualizingPanel.IsVirtualizing="True"
ScrollViewer.VerticalScrollBarVisibility="Auto" VirtualizingPanel.IsContainerVirtualizable="True"
HorizontalContentAlignment="Stretch" MouseLeave="PopupListView_MouseLeave"
HorizontalContentAlignment="Stretch" MouseLeave="PopupListView_MouseLeave" ScrollViewer.PanningMode="VerticalFirst"
Background="Transparent"
x:Name="PopupListView">
<ListView.ItemContainerStyle>
Expand Down
8 changes: 7 additions & 1 deletion JL.Windows/Utilities/PopupWindowUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static TextBlock CreateTextBlock(string name, string text, Brush foregrou

public static TextBox CreateTextBox(string name, string text, Brush foregroundBrush, double fontSize, ContextMenu contextMenu, VerticalAlignment verticalAlignment, Thickness margin)
{
return new TouchScreenTextBox
TouchScreenTextBox textBox = new()
{
Name = name,
Text = text,
Expand All @@ -66,6 +66,12 @@ public static TextBox CreateTextBox(string name, string text, Brush foregroundBr
BorderThickness = new Thickness(0),
Padding = new Thickness(0)
};

// Scrolling doesn’t work when touching a TextBox inside a ListView
// unless the TextBox's PanningMode is set to None explicitly.
ScrollViewer.SetPanningMode(textBox, PanningMode.None);

return textBox;
}

public static Grid CreatePitchAccentGrid(string primarySpelling, string[]? alternativeSpellings,
Expand Down

0 comments on commit b39554b

Please sign in to comment.