Add Ctrl+U and Ctrl+K shortcuts to ChatScene
This commit is contained in:
parent
f6c772a655
commit
8bdd201b28
@ -6,6 +6,7 @@ import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import javafx.animation.RotateTransition;
|
||||
@ -24,19 +25,21 @@ import javafx.scene.shape.Rectangle;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.util.Duration;
|
||||
|
||||
import dev.kske.eventbus.*;
|
||||
import dev.kske.eventbus.Event;
|
||||
import dev.kske.eventbus.EventBus;
|
||||
import dev.kske.eventbus.EventListener;
|
||||
|
||||
import envoy.data.*;
|
||||
import envoy.data.Attachment.AttachmentType;
|
||||
import envoy.data.Message.MessageStatus;
|
||||
import envoy.event.*;
|
||||
import envoy.event.contact.UserOperation;
|
||||
import envoy.event.contact.*;
|
||||
import envoy.exception.EnvoyException;
|
||||
import envoy.util.EnvoyLog;
|
||||
|
||||
import envoy.client.data.*;
|
||||
import envoy.client.data.audio.AudioRecorder;
|
||||
import envoy.client.data.shortcuts.KeyboardMapping;
|
||||
import envoy.client.event.*;
|
||||
import envoy.client.net.*;
|
||||
import envoy.client.ui.*;
|
||||
@ -51,7 +54,7 @@ import envoy.client.util.*;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final class ChatScene implements EventListener, Restorable {
|
||||
public final class ChatScene implements EventListener, Restorable, KeyboardMapping {
|
||||
|
||||
@FXML
|
||||
private ListView<Message> messageList;
|
||||
@ -346,6 +349,11 @@ public final class ChatScene implements EventListener, Restorable {
|
||||
eventBus.removeListener(this);
|
||||
}
|
||||
|
||||
@Event(eventType = AccountDeletion.class)
|
||||
private void onAccountDeletion() {
|
||||
Platform.runLater(chatList::refresh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestore() {
|
||||
updateRemainingCharsLabel();
|
||||
@ -871,4 +879,27 @@ public final class ChatScene implements EventListener, Restorable {
|
||||
: c -> c.getRecipient().getName().toLowerCase()
|
||||
.contains(contactSearch.getText().toLowerCase()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<KeyCombination, Runnable> getKeyboardShortcuts() {
|
||||
final var map = new HashMap<KeyCombination, Runnable>();
|
||||
|
||||
// Delete text before the caret with "Control" + U
|
||||
map.put(new KeyCodeCombination(KeyCode.U, KeyCombination.CONTROL_DOWN), () -> {
|
||||
messageTextArea
|
||||
.setText(messageTextArea.getText().substring(messageTextArea.getCaretPosition()));
|
||||
checkPostConditions(false);
|
||||
});
|
||||
|
||||
// Delete text after the caret with "Control" + K
|
||||
map.put(new KeyCodeCombination(KeyCode.K, KeyCombination.CONTROL_DOWN), () -> {
|
||||
messageTextArea
|
||||
.setText(
|
||||
messageTextArea.getText().substring(0, messageTextArea.getCaretPosition()));
|
||||
checkPostConditions(false);
|
||||
messageTextArea.positionCaret(messageTextArea.getText().length());
|
||||
});
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user