Fixed bug not updating UI after click on context menu item

fixes #11
Additionally, previous commit fixes #5
This commit is contained in:
2020-09-20 15:27:23 +02:00
parent 16a0786d54
commit 4959bc9634
3 changed files with 140 additions and 38 deletions

View File

@ -30,6 +30,7 @@ import envoy.client.data.commands.*;
import envoy.client.event.*;
import envoy.client.net.*;
import envoy.client.ui.*;
import envoy.client.ui.custom.TextInputContextMenu;
import envoy.client.ui.listcell.*;
import envoy.client.util.ReflectionUtil;
import envoy.data.*;
@ -168,6 +169,11 @@ public final class ChatScene implements EventListener, Restorable {
messageList.setCellFactory(MessageListCell::new);
chatList.setCellFactory(new ListCellFactory<>(ChatControl::new));
// JavaFX provides an internal way of populating the context menu of a textarea.
// We, however, need additional functionality.
messageTextArea.setContextMenu(new TextInputContextMenu(messageTextArea, e -> checkKeyCombination(null)));
// Set the icons of buttons and image views
settingsButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("settings", DEFAULT_ICON_SIZE)));
voiceButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("microphone", DEFAULT_ICON_SIZE)));
attachmentButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("attachment", DEFAULT_ICON_SIZE)));
@ -555,7 +561,10 @@ public final class ChatScene implements EventListener, Restorable {
// KeyPressed will be called before the char has been added to the text, hence
// this is needed for the first char
if (messageTextArea.getText().length() == 1) checkPostConditions(e);
if (messageTextArea.getText().length() == 1 && e != null) checkPostConditions(e);
// This is needed for the messageTA context menu
else if (e == null) checkPostConditions(false);
}
/**