Skip to content

Commit

Permalink
update: tool window editor disable
Browse files Browse the repository at this point in the history
  • Loading branch information
muedsa committed Dec 21, 2022
1 parent 19f399e commit 00014ca
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions src/main/java/com/muedsa/intellij/textReader/ui/ReaderWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.*;
import java.io.IOException;
import java.util.Objects;
import java.util.Vector;
Expand Down Expand Up @@ -113,6 +110,47 @@ public ReaderWindow(Project project) {
}

private void createUIComponents(){
//编辑器 禁止编辑 显示光标 WASD键改为方向键
textContent.setEditable(false);
textContent.setCursor(new Cursor(Cursor.TEXT_CURSOR));
textContent.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
JTextPane textPane = (JTextPane) e.getComponent();
textPane.getCaret().setVisible(true);
}

@Override
public void focusLost(FocusEvent e) {
JTextPane textPane = (JTextPane) e.getComponent();
textPane.getCaret().setVisible(false);
}
});

textContent.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
switch (e.getKeyChar()){
case 'w':
e.setKeyCode(KeyEvent.VK_UP);
e.setKeyChar('\uFFFF');
break;
case 'a':
e.setKeyCode(KeyEvent.VK_LEFT);
e.setKeyChar('\uFFFF');
break;
case 's':
e.setKeyCode(KeyEvent.VK_DOWN);
e.setKeyChar('\uFFFF');
break;
case 'd':
e.setKeyCode(KeyEvent.VK_RIGHT);
e.setKeyChar('\uFFFF');
break;
}
}
});

//字体
String[] fontFamilyNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
DefaultComboBoxModel<String> comboBoxModel = new DefaultComboBoxModel<>(fontFamilyNames);
Expand Down

0 comments on commit 00014ca

Please sign in to comment.