From d091a6c3cd0812873bcdef53c51a2f60e12f2b8a Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 5 Apr 2020 16:19:56 +0200 Subject: Add keyboard shortcut (up key) to activate last message correction --- main/src/ui/chat_input/chat_input_controller.vala | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'main/src/ui/chat_input') diff --git a/main/src/ui/chat_input/chat_input_controller.vala b/main/src/ui/chat_input/chat_input_controller.vala index c0878c36..4844ff6c 100644 --- a/main/src/ui/chat_input/chat_input_controller.vala +++ b/main/src/ui/chat_input/chat_input_controller.vala @@ -8,6 +8,8 @@ namespace Dino.Ui { public class ChatInputController : Object { + public signal void activate_last_message_correction(); + public new string? conversation_display_name { get; set; } public string? conversation_topic { get; set; } @@ -30,6 +32,7 @@ public class ChatInputController : Object { reset_input_field_status(); chat_input.chat_text_view.text_view.buffer.changed.connect(on_text_input_changed); + chat_input.chat_text_view.text_view.key_press_event.connect(on_text_input_key_press); chat_text_view_controller.send_text.connect(send_text); chat_input.encryption_widget.encryption_changed.connect(on_encryption_changed); @@ -145,6 +148,16 @@ public class ChatInputController : Object { stream_interactor.get_module(ChatInteraction.IDENTITY).on_message_cleared(conversation); } } + + private bool on_text_input_key_press(EventKey event) { + if (event.keyval == Gdk.Key.Up && chat_input.chat_text_view.text_view.buffer.text == "") { + activate_last_message_correction(); + return true; + } else { + chat_input.chat_text_view.text_view.grab_focus(); + } + return false; + } } } -- cgit v1.2.3-70-g09d2