Lines 60-65
Link Here
|
60 |
import java.awt.dnd.DropTargetEvent; |
60 |
import java.awt.dnd.DropTargetEvent; |
61 |
import java.awt.dnd.DropTargetListener; |
61 |
import java.awt.dnd.DropTargetListener; |
62 |
import java.awt.event.InputEvent; |
62 |
import java.awt.event.InputEvent; |
|
|
63 |
import java.awt.event.KeyEvent; |
63 |
import java.awt.im.InputContext; |
64 |
import java.awt.im.InputContext; |
64 |
import java.lang.reflect.Field; |
65 |
import java.lang.reflect.Field; |
65 |
import java.lang.reflect.InvocationTargetException; |
66 |
import java.lang.reflect.InvocationTargetException; |
Lines 84-89
Link Here
|
84 |
import javax.swing.text.JTextComponent; |
85 |
import javax.swing.text.JTextComponent; |
85 |
import org.openide.util.Lookup; |
86 |
import org.openide.util.Lookup; |
86 |
import org.openide.util.NbBundle; |
87 |
import org.openide.util.NbBundle; |
|
|
88 |
import org.openide.util.Utilities; |
87 |
import org.openide.windows.ExternalDropHandler; |
89 |
import org.openide.windows.ExternalDropHandler; |
88 |
import org.openide.windows.TopComponent; |
90 |
import org.openide.windows.TopComponent; |
89 |
|
91 |
|
Lines 121-126
Link Here
|
121 |
private int fontHeight; |
123 |
private int fontHeight; |
122 |
private int charWidth; |
124 |
private int charWidth; |
123 |
|
125 |
|
|
|
126 |
private static enum AltStatus { |
127 |
DEFAULT, |
128 |
MAY_CONSUME_ALT_PRESSED, |
129 |
IGNORE_NEXT_TYPED, |
130 |
} |
131 |
|
132 |
private AltStatus altStatus = AltStatus.DEFAULT; |
133 |
|
124 |
/** |
134 |
/** |
125 |
* consturctor sets the initial values for horizontal |
135 |
* consturctor sets the initial values for horizontal |
126 |
* and vertical scroll units. |
136 |
* and vertical scroll units. |
Lines 129-134
Link Here
|
129 |
public QuietEditorPane() { |
139 |
public QuietEditorPane() { |
130 |
setFontHeightWidth(getFont()); |
140 |
setFontHeightWidth(getFont()); |
131 |
} |
141 |
} |
|
|
142 |
|
143 |
@Override |
144 |
protected void processKeyEvent(KeyEvent e) { |
145 |
if (Utilities.isMac()) { |
146 |
if (e.getID() == KeyEvent.KEY_PRESSED |
147 |
&& (e.getModifiers() & KeyEvent.ALT_MASK) != 0 |
148 |
&& (e.getModifiers() & KeyEvent.CTRL_MASK) == 0) { |
149 |
altStatus = AltStatus.MAY_CONSUME_ALT_PRESSED; |
150 |
} |
151 |
super.processKeyEvent(e); |
152 |
if (altStatus == AltStatus.MAY_CONSUME_ALT_PRESSED) { |
153 |
altStatus = AltStatus.IGNORE_NEXT_TYPED; |
154 |
LOG.fine("Ignore next typed."); |
155 |
} |
156 |
} else { |
157 |
super.processKeyEvent(e); |
158 |
} |
159 |
} |
160 |
|
161 |
@Override |
162 |
protected void processComponentKeyEvent(KeyEvent e) { |
163 |
// JComponent#processKeyEvent call this method if key event is not consumed at listeners. |
164 |
switch (altStatus) { |
165 |
case MAY_CONSUME_ALT_PRESSED: |
166 |
altStatus = AltStatus.DEFAULT; |
167 |
break; |
168 |
case IGNORE_NEXT_TYPED: |
169 |
if (e.getID() == KeyEvent.KEY_TYPED) { |
170 |
e.consume(); |
171 |
LOG.fine("Ignored: [" + e.getKeyChar() + "]"); |
172 |
} |
173 |
altStatus = AltStatus.DEFAULT; |
174 |
break; |
175 |
default: |
176 |
break; |
177 |
} |
178 |
} |
179 |
|
132 |
|
180 |
|
133 |
public AccessibleContext getAccessibleContext() { |
181 |
public AccessibleContext getAccessibleContext() { |
134 |
AccessibleContext ctx = super.getAccessibleContext(); |
182 |
AccessibleContext ctx = super.getAccessibleContext(); |