send.rs: Reset the scrolling position
This resets the scrolling position while the `msg_entry` widget isn't at its maximum height, so that the cursor never gets at the top when inserting new lines. Closes https://gitlab.gnome.org/World/fractal/issues/288
This commit is contained in:
parent
c68fa2d651
commit
198bb0c64d
1 changed files with 13 additions and 0 deletions
|
@ -7,6 +7,8 @@ use self::sourceview::BufferExt;
|
|||
|
||||
use app::App;
|
||||
|
||||
const MAX_INPUT_HEIGHT: i32 = 100;
|
||||
|
||||
impl App {
|
||||
pub fn connect_send(&self) {
|
||||
let room_message_box = self.ui.builder
|
||||
|
@ -23,6 +25,17 @@ impl App {
|
|||
.get_object("msg_entry")
|
||||
.expect("Couldn't find msg_entry in ui file.");
|
||||
|
||||
let input_scroll = self.ui.builder
|
||||
.get_object::<gtk::ScrolledWindow>("input_scroll")
|
||||
.expect("Can't find input_scroll in ui file.");
|
||||
if let Some(adjustment) = input_scroll.get_vadjustment() {
|
||||
adjustment.connect_value_changed(clone!(msg_entry => move |adj| {
|
||||
if msg_entry.get_allocated_height() < MAX_INPUT_HEIGHT {
|
||||
adj.set_value(0.0);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
let buffer: sourceview::Buffer = self.ui.builder
|
||||
.get_object("msg_entry_buffer")
|
||||
.expect("Couldn't find msg_entry_buffer in ui file.");
|
||||
|
|
Loading…
Reference in a new issue