Skip to content

Commit

Permalink
给播放器弹幕输入框增加回车直接发送逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Jul 3, 2024
1 parent 81a79be commit 1c5c561
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Desktop/Views/Windows/VlcPlayWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBox Name="DanmaOnly_DanmaInput" Grid.Column="0" Margin="10,10,10,4" PlaceholderText="输入弹幕内容" Text="" TextChanged="DanmaOnly_DanmaInput_TextChanged"/>
<ui:TextBox Name="DanmaOnly_DanmaInput" Grid.Column="0" Margin="10,10,10,4" PlaceholderText="输入弹幕内容" Text="" TextChanged="DanmaOnly_DanmaInput_TextChanged" KeyDown="DanmaOnly_DanmaInput_KeyDown"/>
<ui:Button Grid.Column="1" Margin="0,10,10,4" Content="发送" FontSize="20" HorizontalAlignment="Right" Icon="{ui:SymbolIcon Send20}" Click="Send_Danma_Button_Click"/>
</Grid>
</Grid>
Expand Down
16 changes: 15 additions & 1 deletion Desktop/Views/Windows/VlcPlayWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,21 @@ private void MenuItem_TopMost_Click(object sender, RoutedEventArgs e)
{
this.Topmost = true;
TopMostSwitch = true;
SetNotificatom("打开窗口置顶",$"{roomCard.Name}({roomCard.RoomId})窗口置顶已打开");
SetNotificatom("打开窗口置顶", $"{roomCard.Name}({roomCard.RoomId})窗口置顶已打开");
}
}

private void DanmaOnly_DanmaInput_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.KeyStates == Keyboard.GetKeyStates(Key.Enter))
{
string T = DanmaOnly_DanmaInput.Text;
if (string.IsNullOrEmpty(T) && T.Length > 20)
{
return;
}
Danmu.SendDanmu(roomCard.RoomId.ToString(), T);
DanmaOnly_DanmaInput.Clear();
}
}
}
Expand Down

0 comments on commit 1c5c561

Please sign in to comment.