mirror of https://github.com/zlatinb/muwire
prevent duplicate newline when user presses enter
parent
d4f46be3b7
commit
ea5fcbecff
|
@ -59,13 +59,18 @@ class ChatEntryPane extends JTextPane {
|
|||
}
|
||||
})
|
||||
|
||||
KeyStroke back = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)
|
||||
InputMap inputMap = getInputMap()
|
||||
ActionMap actionMap = getActionMap()
|
||||
|
||||
KeyStroke back = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)
|
||||
Object backObject = inputMap.get(back)
|
||||
backspaceAction = actionMap.get(backObject)
|
||||
actionMap.put(backObject, new BackspaceAction(backspaceAction))
|
||||
|
||||
Action noAction = new NullAction()
|
||||
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)
|
||||
Object enterObject = inputMap.get(enter)
|
||||
actionMap.put(enterObject, noAction)
|
||||
}
|
||||
|
||||
private String getTextSinceAt(){
|
||||
|
@ -198,4 +203,14 @@ class ChatEntryPane extends JTextPane {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class NullAction extends UIAction {
|
||||
NullAction() {
|
||||
super("nothing")
|
||||
}
|
||||
|
||||
@Override
|
||||
void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue