Does not lose focus from chat write area when clicking on the conversation panel (reverts previous commit and adds new fix).

fix-message-formatting 5240
Damian Minkov 12 years ago
parent fe39617026
commit 64b51e078d

@ -237,7 +237,6 @@ public ChatConversationPanel(ChatConversationContainer chatContainer)
this.chatTextPane.setEditable(false); this.chatTextPane.setEditable(false);
this.chatTextPane.setDocument(document); this.chatTextPane.setDocument(document);
this.chatTextPane.setDragEnabled(true); this.chatTextPane.setDragEnabled(true);
this.chatTextPane.setFocusable(false);
chatTextPane.putClientProperty( chatTextPane.putClientProperty(
JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

@ -64,6 +64,7 @@ public class ChatPanel
ChatRoomLocalUserRoleListener, ChatRoomLocalUserRoleListener,
ChatRoomMemberPropertyChangeListener, ChatRoomMemberPropertyChangeListener,
FileTransferStatusListener, FileTransferStatusListener,
KeyEventDispatcher,
Skinnable Skinnable
{ {
/** /**
@ -228,6 +229,9 @@ public ChatPanel(ChatContainer chatContainer)
} }
this.addComponentListener(new TabSelectionComponentListener()); this.addComponentListener(new TabSelectionComponentListener());
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addKeyEventDispatcher(this);
} }
/** /**
@ -445,6 +449,9 @@ public ChatSession getChatSession()
*/ */
public void dispose() public void dispose()
{ {
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.removeKeyEventDispatcher(this);
writeMessagePanel.dispose(); writeMessagePanel.dispose();
chatSession.dispose(); chatSession.dispose();
conversationPanel.dispose(); conversationPanel.dispose();
@ -3115,4 +3122,27 @@ public void chatConferenceDescriptionSent(
chatConferencesDialog.setCreatePanelEnabled(!available); chatConferencesDialog.setCreatePanelEnabled(!available);
chatConferencesDialog.setEndConferenceButtonEnabled(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 <tt>KeyEvent</tt> to dispatch.
* @return <tt>true</tt> if the KeyboardFocusManager should take no
* further action with regard to the KeyEvent; <tt>false</tt>
* 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;
}
} }

Loading…
Cancel
Save