@@ -43,7 +43,6 @@ abstract public class EditorButton extends JComponent
4343 protected boolean pressed ;
4444 protected boolean selected ;
4545 protected boolean rollover ;
46- // protected JLabel rolloverLabel;
4746 protected boolean shift ;
4847
4948 protected Image enabledImage ;
@@ -55,7 +54,6 @@ abstract public class EditorButton extends JComponent
5554 protected Image gradient ;
5655
5756 protected EditorToolbar toolbar ;
58- // protected Mode mode;
5957
6058
6159 public EditorButton (EditorToolbar parent , String name , String title ) {
@@ -128,50 +126,8 @@ public void paintComponent(Graphics g) {
128126 }
129127
130128
131- // public String toString() {
132- // switch (this) {
133- // case DISABLED: return "disabled";
134- // case ENABLED: return "enabled";
135- // case SELECTED: return "selected";
136- // case ROLLOVER: return "rollover";
137- // case PRESSED: return "pressed";
138- //
139- //// for (State bs : State.values()) {
140- //// Image image = mode.loadImage(bs.getFilename(name));
141- //// if (image != null) {
142- //// imageMap.put(bs, image);
143- //// }
144- //// }
145- ////
146- //// enabled = true;
147- //// //updateState();
148- //// setState(State.ENABLED);
149- // }
150-
151-
152- // public void setReverse() {
153- // gradient = mode.makeGradient("reversed", DIM, DIM);
154- // }
155-
156-
157- // public void setGradient(Image gradient) {
158- // this.gradient = gradient;
159- // }
160-
161-
162- // public void setRolloverLabel(JLabel label) {
163- // rolloverLabel = label;
164- // }
165-
166-
167129 @ Override
168- public void mouseClicked (MouseEvent e ) {
169- // if (isEnabled()) {
170- // shift = e.isShiftDown();
171- // actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
172- // null, e.getModifiers()));
173- // }
174- }
130+ public void mouseClicked (MouseEvent e ) { }
175131
176132
177133 public boolean isShiftDown () {
@@ -181,12 +137,17 @@ public boolean isShiftDown() {
181137
182138 @ Override
183139 public void mousePressed (MouseEvent e ) {
184- setPressed (true );
185-
186- // Need to fire here (or on mouse up) because mouseClicked()
140+ // Using mousePressed() (or mouseReleased()) because mouseClicked()
187141 // won't be fired if the user nudges the mouse while clicking.
188142 // https://github.com/processing/processing/issues/3529
143+ setPressed (true );
144+
189145 shift = e .isShiftDown ();
146+
147+ // It looks like ActionEvent expects old-style modifiers,
148+ // so the e.getModifiers() call here may be correct.
149+ // TODO Look into how this is getting used in Modes,
150+ // and either update or add ignore to the deprecation [fry 191008]
190151 actionPerformed (new ActionEvent (this , ActionEvent .ACTION_PERFORMED ,
191152 null , e .getModifiers ()));
192153 }
@@ -211,25 +172,6 @@ public void setSelected(boolean selected) {
211172 }
212173
213174
214- /*
215- @Override
216- public void keyTyped(KeyEvent e) { }
217-
218-
219- @Override
220- public void keyReleased(KeyEvent e) {
221- updateRollover(e);
222- }
223-
224-
225- @Override
226- public void keyPressed(KeyEvent e) {
227- System.out.println(e);
228- updateRollover(e);
229- }
230- */
231-
232-
233175 public String getRolloverText (InputEvent e ) {
234176 if (e .isShiftDown ()) {
235177 return titleShift ;
@@ -240,42 +182,15 @@ public String getRolloverText(InputEvent e) {
240182 }
241183
242184
243- /*
244- public void updateRollover(InputEvent e) {
245- if (rolloverLabel != null) {
246- if (e.isShiftDown()) {
247- rolloverLabel.setText(titleShift);
248- } else if (e.isAltDown()) {
249- rolloverLabel.setText(titleAlt);
250- } else {
251- rolloverLabel.setText(title);
252- }
253- }
254- }
255- */
256-
257-
258185 @ Override
259186 public void mouseEntered (MouseEvent e ) {
260187 toolbar .setRollover (this , e );
261- /*
262- rollover = true;
263- updateRollover(e);
264- repaint();
265- */
266188 }
267189
268190
269191 @ Override
270192 public void mouseExited (MouseEvent e ) {
271193 toolbar .setRollover (null , e );
272- /*
273- rollover = false;
274- if (rolloverLabel != null) {
275- rolloverLabel.setText("");
276- }
277- repaint();
278- */
279194 }
280195
281196
@@ -289,11 +204,6 @@ public void mouseMoved(MouseEvent e) { }
289204
290205 abstract public void actionPerformed (ActionEvent e );
291206
292- // @Override
293- // public void actionPerformed(ActionEvent e) {
294- // // To be overridden by all subclasses
295- // }
296-
297207
298208 @ Override
299209 public Dimension getPreferredSize () {
@@ -311,58 +221,4 @@ public Dimension getMinimumSize() {
311221 public Dimension getMaximumSize () {
312222 return getPreferredSize ();
313223 }
314-
315-
316- // public Image getImage() {
317- // return imageMap.get(state);
318- // }
319- //
320- //
321- //// protected void updateState() {
322- //// state = ButtonState.ENABLED;
323- //// }
324- //
325- //
326- // public void setEnabled(boolean enabled) {
327- // this.enabled = enabled;
328- // if (enabled) {
329- // if (state == State.DISABLED) {
330- // setState(State.ENABLED);
331- // }
332- // } else {
333- // if (state == State.ENABLED) {
334- // setState(State.DISABLED);
335- // }
336- // }
337- // }
338- //
339- //
340- // public void setState(State state) {
341- // this.state = state;
342- // }
343-
344-
345- // public enum State {
346- // DISABLED, ENABLED, SELECTED, ROLLOVER, PRESSED;
347- //
348- // /**
349- // * @param name the root name
350- // * @return
351- // */
352- // public String getFilename(String name) {
353- // final int res = Toolkit.highResDisplay() ? 2 : 1;
354- // return name + "-" + toString() + "-" + res + "x.png";
355- // }
356- //
357- // public String toString() {
358- // switch (this) {
359- // case DISABLED: return "disabled";
360- // case ENABLED: return "enabled";
361- // case SELECTED: return "selected";
362- // case ROLLOVER: return "rollover";
363- // case PRESSED: return "pressed";
364- // }
365- // return null;
366- // }
367- // }
368224}
0 commit comments