Changed KeyEvent.isShiftDown() and KeyEvent.isControlDown() to
comparisons between KeyEvent.getModifiers() and InputEvent.SHIFT_MASK
and CTRL_MASK.
Also switched the order of shift and control handling in
MouseInputHandler.mousePressed to correspond to the JDK's behaviour.
Patch attached.
2005-07-28 Anthony Balkissoon <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicListUI.java:
(KeyHandler.keyPressed): Replaced calls to KeyEvent.isShiftDown() and
isControlDown() with comparisons of KeyEvent.getModifiers() and
InputEvent.SHIFT_MASK and CTRL_MASK.
(MouseInputHandler.mouseClicked): Reordered SHIFT and CTRL modifier
actions to correspond to JDK. Note the JDK simply ignores other
modifiers so isShiftDown() and isControlDown() are okay for mouse
input.
-Tony
Index: javax/swing/plaf/basic/BasicListUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicListUI.java,v
retrieving revision 1.28
diff -u -r1.28 BasicListUI.java
--- javax/swing/plaf/basic/BasicListUI.java 27 Jul 2005 19:48:44 -0000 1.28
+++ javax/swing/plaf/basic/BasicListUI.java 28 Jul 2005 15:24:44 -0000
@@ -49,6 +49,7 @@
import java.awt.event.ComponentListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
+import java.awt.event.InputEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
@@ -208,12 +209,12 @@
if ((evt.getKeyCode() == KeyEvent.VK_DOWN)
|| (evt.getKeyCode() == KeyEvent.VK_KP_DOWN))
{
- if (!evt.isShiftDown())
+ if (evt.getModifiers() == 0)
{
BasicListUI.this.list.clearSelection();
BasicListUI.this.list.setSelectedIndex(Math.min(lead+1,max));
}
- else
+ else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
{
BasicListUI.this.list.getSelectionModel().
setLeadSelectionIndex(Math.min(lead+1,max));
@@ -222,12 +223,12 @@
else if ((evt.getKeyCode() == KeyEvent.VK_UP)
|| (evt.getKeyCode() == KeyEvent.VK_KP_UP))
{
- if (!evt.isShiftDown())
+ if (evt.getModifiers() == 0)
{
BasicListUI.this.list.clearSelection();
BasicListUI.this.list.setSelectedIndex(Math.max(lead-1,0));
}
- else
+ else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
{
BasicListUI.this.list.getSelectionModel().
setLeadSelectionIndex(Math.max(lead-1,0));
@@ -242,13 +243,16 @@
// FIXME: implement, need JList.ensureIndexIsVisible to work
}
else if (evt.getKeyCode() == KeyEvent.VK_BACK_SLASH
- && evt.isControlDown())
+ && (evt.getModifiers() == InputEvent.CTRL_MASK))
{
BasicListUI.this.list.clearSelection();
}
else if ((evt.getKeyCode() == KeyEvent.VK_HOME)
|| evt.getKeyCode() == KeyEvent.VK_END)
{
+ if (evt.getModifiers() != 0 &&
+ evt.getModifiers() != InputEvent.SHIFT_MASK)
+ return;
// index is either 0 for HOME, or last cell for END
int index = (evt.getKeyCode() == KeyEvent.VK_HOME) ? 0 : max;
@@ -264,14 +268,16 @@
setLeadSelectionIndex(index);
}
else if ((evt.getKeyCode() == KeyEvent.VK_A || evt.getKeyCode()
- == KeyEvent.VK_SLASH) && evt.isControlDown())
+ == KeyEvent.VK_SLASH) && (evt.getModifiers() ==
+ InputEvent.CTRL_MASK))
{
BasicListUI.this.list.setSelectionInterval(0, max);
// this next line is to restore the lead selection index to the old
// position, because select-all should not change the lead index
BasicListUI.this.list.addSelectionInterval(lead, lead);
}
- else if (evt.getKeyCode() == KeyEvent.VK_SPACE && evt.isControlDown())
+ else if (evt.getKeyCode() == KeyEvent.VK_SPACE &&
+ (evt.getModifiers() == InputEvent.CTRL_MASK))
{
BasicListUI.this.list.getSelectionModel().
setLeadSelectionIndex(Math.min(lead+1,max));
@@ -300,17 +306,7 @@
int index = BasicListUI.this.locationToIndex(list, click);
if (index == -1)
return;
- if (event.isControlDown())
- {
- if (BasicListUI.this.list.getSelectionMode() ==
- ListSelectionModel.SINGLE_SELECTION)
- BasicListUI.this.list.setSelectedIndex(index);
- else if (BasicListUI.this.list.isSelectedIndex(index))
- BasicListUI.this.list.removeSelectionInterval(index,index);
- else
- BasicListUI.this.list.addSelectionInterval(index,index);
- }
- else if (event.isShiftDown())
+ if (event.isShiftDown())
{
if (BasicListUI.this.list.getSelectionMode() ==
ListSelectionModel.SINGLE_SELECTION)
@@ -333,6 +329,16 @@
// The most natural thing to do is the following:
BasicListUI.this.list.getSelectionModel().
setLeadSelectionIndex(index);
+ }
+ else if (event.isControlDown())
+ {
+ if (BasicListUI.this.list.getSelectionMode() ==
+ ListSelectionModel.SINGLE_SELECTION)
+ BasicListUI.this.list.setSelectedIndex(index);
+ else if (BasicListUI.this.list.isSelectedIndex(index))
+ BasicListUI.this.list.removeSelectionInterval(index,index);
+ else
+ BasicListUI.this.list.addSelectionInterval(index,index);
}
else
BasicListUI.this.list.setSelectedIndex(index);
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches