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 4dd261739..716616408 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 ChatConversationPanel(ChatConversationContainer chatContainer) 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 a4f50c5c7..bf325c607 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 ChatPanel(ChatContainer chatContainer) } this.addComponentListener(new TabSelectionComponentListener()); + + KeyboardFocusManager.getCurrentKeyboardFocusManager() + .addKeyEventDispatcher(this); } /** @@ -445,6 +449,9 @@ public ChatSession getChatSession() */ public void dispose() { + KeyboardFocusManager.getCurrentKeyboardFocusManager() + .removeKeyEventDispatcher(this); + writeMessagePanel.dispose(); chatSession.dispose(); conversationPanel.dispose(); @@ -3115,4 +3122,27 @@ public void chatConferenceDescriptionSent( 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; + } }