Here's a patch against trunk that fixes the problem :)

-- Edvin

Den 15.05.2011 09:28, skrev Edvin Syse:
When reading the source code of TerraListViewSkin, it looks like this is
indeed the case. It should be a simple fix, though...

Den 15.05.2011 09:11, skrev Edvin Syse:
Hm.. actually, you are right.. I get the same behavior as you describe.
Even when releasing shift, pressing up arrow doesn't release the
selection. It kind of looks like the "cursor" is on the first row,
because if you select let's say three elements in the middle of the list
with shift+down, releasing shift and pressing up arrow will select the
element at the beginning of the list. But again, then pressing down
arrow should fix the problem in your example, but it doesn't...

-- Edvin

Den 15.05.2011 09:06, skrev Edvin Syse:
I think you might be confused by the behavior of using arrow keys while
holding down shift. When shift is pressed and you press the down arrow,
the next element after the current selection is added to the selection.
If you press the up arrow, the element in front of the current selection
range is selected. Hence, when all the elements are selected, pressing
up or down is not supposed to change anything. If you release shift, the
selection changes (to one element), right?

-- Edvin

Den 15.05.2011 01:46, skrev Andrei Pozolotin:
BUG: ListView selection with keys

1) if you take this example
http://pivot.apache.org/tutorials/lists.html

2) select with mouse first item

3) then with keys: shift + down continue select until all list items
are
selected

4) now ListView no longer responds to key strokes

this is on 64 bit ubuntu 10.04 and jdk 1.6.0 _25

verified same bug in current trunk

Index: wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
===================================================================
--- wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java        
(revision 1101265)
+++ wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java        
(revision )
@@ -1009,6 +1009,7 @@
             case Keyboard.KeyCode.UP: {
                 if (selectMode != ListView.SelectMode.NONE) {
                     int index = listView.getFirstSelectedIndex();
+                    int count = listView.getListData().getLength();
 
                     do {
                         index--;
@@ -1022,6 +1023,15 @@
                         } else {
                             listView.setSelectedIndex(index);
                         }
+                    } else if (!Keyboard.isPressed(Keyboard.Modifier.SHIFT) && 
listView.getSelectMode() == ListView.SelectMode.MULTI && count == 
listView.getLastSelectedIndex() + 1) {
+                        index = listView.getLastSelectedIndex();
+
+                        do {
+                            index--;
+                        } while (index >= 0 &&
+                            listView.isItemDisabled(index));
+
+                        listView.setSelectedIndex(Math.max(0, index));
                     }
 
                     consumed = true;
@@ -1047,6 +1057,14 @@
                         } else {
                             listView.setSelectedIndex(index);
                         }
+                    } else if (!Keyboard.isPressed(Keyboard.Modifier.SHIFT) && 
listView.getSelectMode() == ListView.SelectMode.MULTI && count == 
listView.getLastSelectedIndex() + 1) {
+                        index = 0;
+                        do {
+                            index++;
+                        } while (index < count &&
+                            listView.isItemDisabled(index));
+
+                        
listView.setSelectedIndex(Math.min(listView.getLastSelectedIndex(), index));
                     }
 
                     consumed = true;

Reply via email to