Added "Copy and Send" capability
additionally added context menu to delete a contact, currently without function
This commit is contained in:
parent
4d81b741bb
commit
cb0ff03072
@ -63,6 +63,9 @@ public final class ChatScene {
|
|||||||
@FXML
|
@FXML
|
||||||
private Label remainingChars;
|
private Label remainingChars;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private MenuItem deleteContactMenuItem;
|
||||||
|
|
||||||
private LocalDB localDB;
|
private LocalDB localDB;
|
||||||
private Client client;
|
private Client client;
|
||||||
private WriteProxy writeProxy;
|
private WriteProxy writeProxy;
|
||||||
@ -176,6 +179,7 @@ public final class ChatScene {
|
|||||||
.orElseGet(() -> { final var chat = new Chat(user); localDB.getChats().add(chat); return chat; });
|
.orElseGet(() -> { final var chat = new Chat(user); localDB.getChats().add(chat); return chat; });
|
||||||
|
|
||||||
messageList.setItems(FXCollections.observableList(currentChat.getMessages()));
|
messageList.setItems(FXCollections.observableList(currentChat.getMessages()));
|
||||||
|
deleteContactMenuItem.setText("Delete " + user.getName());
|
||||||
|
|
||||||
// Read the current chat
|
// Read the current chat
|
||||||
try {
|
try {
|
||||||
@ -330,4 +334,21 @@ public final class ChatScene {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void quoteMessage() {}
|
private void quoteMessage() {}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void deleteContact() {
|
||||||
|
// TODO: Fill with content
|
||||||
|
userList.getSelectionModel().getSelectedItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void copyAndPostMessage() {
|
||||||
|
final var messageText = messageTextArea.getText();
|
||||||
|
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null);
|
||||||
|
postMessage();
|
||||||
|
messageTextArea.setText(messageText);
|
||||||
|
updateRemainingCharsLabel();
|
||||||
|
postButton.setDisable(messageText.isBlank());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,15 @@
|
|||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||||
</padding></ListView>
|
</padding>
|
||||||
|
<contextMenu>
|
||||||
|
<ContextMenu anchorLocation="CONTENT_TOP_LEFT">
|
||||||
|
<items>
|
||||||
|
<MenuItem fx:id="deleteContactMenuItem" mnemonicParsing="false" text="Delete" onAction="#deleteContact"/>
|
||||||
|
</items>
|
||||||
|
</ContextMenu>
|
||||||
|
</contextMenu>
|
||||||
|
</ListView>
|
||||||
<Label fx:id="contactLabel" prefHeight="16.0" prefWidth="250.0" text="Select a contact to chat with" GridPane.columnSpan="2">
|
<Label fx:id="contactLabel" prefHeight="16.0" prefWidth="250.0" text="Select a contact to chat with" GridPane.columnSpan="2">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets bottom="5.0" left="10.0" right="5.0" top="10.0" />
|
<Insets bottom="5.0" left="10.0" right="5.0" top="10.0" />
|
||||||
@ -72,7 +80,15 @@
|
|||||||
</padding>
|
</padding>
|
||||||
<tooltip>
|
<tooltip>
|
||||||
<Tooltip anchorLocation="WINDOW_TOP_LEFT" autoHide="true" maxWidth="350.0" text="Click this button to send the message. If it is disabled, you first have to select a contact to send it to. A message may automatically be sent when you press (Ctrl + ) Enter, according to your preferences. Additionally sends a message when pressing "Alt" + "P"." wrapText="true" />
|
<Tooltip anchorLocation="WINDOW_TOP_LEFT" autoHide="true" maxWidth="350.0" text="Click this button to send the message. If it is disabled, you first have to select a contact to send it to. A message may automatically be sent when you press (Ctrl + ) Enter, according to your preferences. Additionally sends a message when pressing "Alt" + "P"." wrapText="true" />
|
||||||
</tooltip></Button>
|
</tooltip>
|
||||||
|
<contextMenu>
|
||||||
|
<ContextMenu anchorLocation="CONTENT_TOP_LEFT">
|
||||||
|
<items>
|
||||||
|
<MenuItem mnemonicParsing="false" text="Copy and Send" onAction="#copyAndPostMessage"/>
|
||||||
|
</items>
|
||||||
|
</ContextMenu>
|
||||||
|
</contextMenu>
|
||||||
|
</Button>
|
||||||
<TextArea fx:id="messageTextArea" disable="true" onInputMethodTextChanged="#messageTextUpdated" onKeyPressed="#checkPostConditions" onKeyTyped="#checkKeyCombination" prefHeight="200.0" prefWidth="200.0" wrapText="true" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
<TextArea fx:id="messageTextArea" disable="true" onInputMethodTextChanged="#messageTextUpdated" onKeyPressed="#checkPostConditions" onKeyTyped="#checkKeyCombination" prefHeight="200.0" prefWidth="200.0" wrapText="true" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets bottom="10.0" left="5.0" right="5.0" top="5.0" />
|
<Insets bottom="10.0" left="5.0" right="5.0" top="5.0" />
|
||||||
|
Reference in New Issue
Block a user