From 64b51e078dddc12e4b06e7c9d2d76a9ce20a6092 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Thu, 5 Jun 2014 15:36:45 +0300 Subject: Does not lose focus from chat write area when clicking on the conversation panel (reverts previous commit and adds new fix). --- .../impl/gui/main/chat/ChatConversationPanel.java | 1 - .../communicator/impl/gui/main/chat/ChatPanel.java | 30 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java index 4dd2617..7166164 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java @@ -237,7 +237,6 @@ public class ChatConversationPanel this.chatTextPane.setEditable(false); this.chatTextPane.setDocument(document); this.chatTextPane.setDragEnabled(true); - this.chatTextPane.setFocusable(false); chatTextPane.putClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java index a4f50c5..bf325c6 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java @@ -64,6 +64,7 @@ public class ChatPanel ChatRoomLocalUserRoleListener, ChatRoomMemberPropertyChangeListener, FileTransferStatusListener, + KeyEventDispatcher, Skinnable { /** @@ -228,6 +229,9 @@ public class ChatPanel } this.addComponentListener(new TabSelectionComponentListener()); + + KeyboardFocusManager.getCurrentKeyboardFocusManager() + .addKeyEventDispatcher(this); } /** @@ -445,6 +449,9 @@ public class ChatPanel */ public void dispose() { + KeyboardFocusManager.getCurrentKeyboardFocusManager() + .removeKeyEventDispatcher(this); + writeMessagePanel.dispose(); chatSession.dispose(); conversationPanel.dispose(); @@ -3115,4 +3122,27 @@ public class ChatPanel chatConferencesDialog.setCreatePanelEnabled(!available); chatConferencesDialog.setEndConferenceButtonEnabled(available); } + + /** + * Dispatches key events and process those that were generated when + * conversationPanel ChatTextPane is focused and they were targeting the + * write message panel. + * @param e the KeyEvent to dispatch. + * @return true if the KeyboardFocusManager should take no + * further action with regard to the KeyEvent; false + * otherwise. + */ + public boolean dispatchKeyEvent(KeyEvent e) + { + if(e.getSource() != conversationPanel.getChatTextPane() + || writeMessagePanel.getEditorPane().isFocusOwner()) + return false; + + writeMessagePanel.getEditorPane().requestFocusInWindow(); + + KeyboardFocusManager.getCurrentKeyboardFocusManager() + .redispatchEvent(writeMessagePanel.getEditorPane(), e); + + return true; + } } -- cgit v1.1