Implement Chat Autoscroll

This commit is contained in:
Alan Moon 2025-06-20 17:08:20 -07:00
parent 9ba107c964
commit 85a0ecc4f4
4 changed files with 16 additions and 2 deletions

View File

@ -63,6 +63,7 @@
rtxtChat.Size = new Size(593, 250);
rtxtChat.TabIndex = 3;
rtxtChat.Text = "";
rtxtChat.TextChanged += rtxtChat_TextChanged;
//
// Chat
//

View File

@ -68,6 +68,12 @@ namespace qtc_net_client_2.Forms
btnSend_Click(sender, e);
}
private void rtxtChat_TextChanged(object sender, EventArgs e)
{
rtxtChat.SelectionStart = rtxtChatbox.Text.Length;
rtxtChat.ScrollToCaret();
}
private void _gatewayService_OnServerMessageReceived(object? sender, EventArgs e)
{
var msgEventArgs = (ServerMessageEventArgs)e;

View File

@ -44,6 +44,7 @@
rtxtChat.Size = new Size(593, 317);
rtxtChat.TabIndex = 6;
rtxtChat.Text = "";
rtxtChat.TextChanged += rtxtChat_TextChanged;
//
// btnSend
//

View File

@ -83,6 +83,12 @@ namespace qtc_net_client_2.Forms
btnSend_Click(sender, e);
}
private void rtxtChat_TextChanged(object sender, EventArgs e)
{
rtxtChat.SelectionStart = rtxtChatbox.Text.Length;
rtxtChat.ScrollToCaret();
}
private void Messages_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null && e.NewItems.Count > 0)