14
14
using System . Threading . Tasks ;
15
15
using Windows . Foundation ;
16
16
using Windows . Storage ;
17
+ using Windows . System ;
17
18
using Windows . UI . Core ;
18
19
using Windows . UI . ViewManagement ;
19
20
using Windows . UI . Xaml ;
@@ -36,7 +37,6 @@ public sealed partial class Conversation : UserControl, INotifyPropertyChanged
36
37
{
37
38
private readonly ILogger Logger = LibsignalLogging . CreateLogger < Conversation > ( ) ;
38
39
public event PropertyChangedEventHandler PropertyChanged ;
39
- private bool SendingMessage = false ;
40
40
private SignalConversation SignalConversation ;
41
41
public VirtualizedCollection Collection ;
42
42
private CoreWindowActivationState ActivationState = CoreWindowActivationState . Deactivated ;
@@ -283,18 +283,23 @@ public AppendResult Append(Message sm)
283
283
284
284
private async void TextBox_KeyDown ( object sender , KeyRoutedEventArgs e )
285
285
{
286
- if ( e . Key == Windows . System . VirtualKey . Enter )
286
+ if ( e . Key == VirtualKey . Enter )
287
287
{
288
- // this fixes double send by enter repeat
289
- if ( ! SendingMessage )
288
+ e . Handled = true ; // Prevent KeyDown from firing twice on W10 CU
289
+ bool shift = CoreWindow . GetForCurrentThread ( ) . GetKeyState ( VirtualKey . Shift ) . HasFlag ( CoreVirtualKeyStates . Down ) ;
290
+ if ( shift )
290
291
{
291
- SendingMessage = true ;
292
- bool sendMessageResult = await GetMainPageVm ( ) . SendMessageButton_Click ( InputTextBox . Text ) ;
292
+ InputTextBox . Text += "\r " ;
293
+ InputTextBox . SelectionStart = InputTextBox . Text . Length ;
294
+ InputTextBox . SelectionLength = 0 ;
295
+ }
296
+ else
297
+ {
298
+ bool sendMessageResult = await GetMainPageVm ( ) . SendMessage ( InputTextBox . Text ) ;
293
299
if ( sendMessageResult )
294
300
{
295
301
InputTextBox . Text = string . Empty ;
296
302
}
297
- SendingMessage = false ;
298
303
}
299
304
}
300
305
}
@@ -310,8 +315,7 @@ private void ScrollToBottom()
310
315
311
316
private async void SendMessageButton_Click ( object sender , RoutedEventArgs e )
312
317
{
313
- InputTextBox . Focus ( FocusState . Programmatic ) ;
314
- bool sendMessageResult = await GetMainPageVm ( ) . SendMessageButton_Click ( InputTextBox . Text ) ;
318
+ bool sendMessageResult = await GetMainPageVm ( ) . SendMessage ( InputTextBox . Text ) ;
315
319
if ( sendMessageResult )
316
320
{
317
321
InputTextBox . Text = string . Empty ;
0 commit comments