gtk-qq
gtk-qq copied to clipboard
Scroll down chatroom view aumatically when pushing new message.
Requirements Description
- When the user sends or receives a message, and the chatroom is right at the bottom, the chatroom view should automatically scroll down the view to the bottom.
- If chatroom is not right at the bottom, no scroll operation is needed.
My Attempt
let adjustment = view.vadjustment();
adjustment.connect_changed(|adjustment| {
// Scroll down the view
let view_height = adjustment.upper() - adjustment.page_size();
adjustment.set_value(view_height);
});
That's what I wrote trying to implement this function. However, it has a weird behaviour:
https://user-images.githubusercontent.com/21173956/169246535-3ce22603-9ad6-4675-a57b-790deb28fc82.mp4
As the video shows: the scrollbar updates, while the view does not.
Hopefully this message does help to you if you want to contribute about it.
PR WELCOME
我将那部分代码加入后测试的结果是: 会滚动,但是不会滚动到底,大概会距离滚动到底差一个对话框
https://github.com/melix99/telegrand/issues/13