Skip to content

Commit 7b19f9b

Browse files
committed
Add refresh button to refresh webview on CaptchaPage
KeyDown and KeyUp events don't work with webviews.
1 parent d0259a3 commit 7b19f9b

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

Signal-Windows/Views/CaptchaPage.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,11 @@
1010

1111
<Grid>
1212
<WebView x:Name="webView" Source="{x:Bind Vm.WebViewSource, Mode=TwoWay}"/>
13+
<Button x:Name="refreshButton" VerticalAlignment="Bottom" HorizontalAlignment="Center" Click="refreshButton_Click">
14+
<StackPanel Orientation="Horizontal">
15+
<SymbolIcon Symbol="Refresh"/>
16+
<TextBlock Text="Refresh" Margin="8,0,0,0"/>
17+
</StackPanel>
18+
</Button>
1319
</Grid>
1420
</Page>

Signal-Windows/Views/CaptchaPage.xaml.cs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,8 @@ public CaptchaPageViewModel Vm
3333

3434
public CaptchaPage()
3535
{
36-
// pretty much the only reason
3736
this.InitializeComponent();
3837
Vm.View = this;
39-
KeyDown += CaptchaPage_KeyDown;
40-
}
41-
42-
private bool IsCtrlKeyPressed()
43-
{
44-
var ctrlState = CoreWindow.GetForCurrentThread().GetKeyState(Windows.System.VirtualKey.Control);
45-
return (ctrlState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
46-
}
47-
48-
private void CaptchaPage_KeyDown(object sender, KeyRoutedEventArgs e)
49-
{
50-
if ((IsCtrlKeyPressed() && e.Key == Windows.System.VirtualKey.R) ||
51-
e.Key == Windows.System.VirtualKey.F5)
52-
{
53-
webView.Refresh();
54-
}
5538
}
5639

5740
protected override void OnNavigatedTo(NavigationEventArgs e)
@@ -65,5 +48,11 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
6548
base.OnNavigatingFrom(e);
6649
Vm.OnNavigatingFrom();
6750
}
51+
52+
private void refreshButton_Click(object sender, RoutedEventArgs e)
53+
{
54+
// KeyDown event doesn't work with WebView so just use a button to allow users to refresh the page
55+
webView.Refresh();
56+
}
6857
}
6958
}

0 commit comments

Comments
 (0)