1899 ! |
1899 ! |
1900 |
1900 |
1901 buttonPress:button x:x y:y |
1901 buttonPress:button x:x y:y |
1902 "a button was pressed - handle selection here |
1902 "a button was pressed - handle selection here |
1903 " |
1903 " |
1904 |rowNr colNr menu sz first| |
1904 |rowNr colNr menu sz first sensor| |
1905 |
1905 |
1906 self isEnabled ifFalse:[^ self]. |
1906 self isEnabled ifFalse:[^ self]. |
|
1907 |
|
1908 sensor := self sensor. |
1907 |
1909 |
1908 clickPosition := nil. |
1910 clickPosition := nil. |
1909 dragAccessPoint := nil. |
1911 dragAccessPoint := nil. |
1910 dragIsActive := false. |
1912 dragIsActive := false. |
1911 |
1913 |
1917 ( (button == 1 or:[button == #select]) |
1919 ( (button == 1 or:[button == #select]) |
1918 and:[(rowNr := self yVisibleToRowNr:y) notNil |
1920 and:[(rowNr := self yVisibleToRowNr:y) notNil |
1919 and:[(colNr := self xVisibleToColNr:x) notNil]] |
1921 and:[(colNr := self xVisibleToColNr:x) notNil]] |
1920 ) ifTrue:[ |
1922 ) ifTrue:[ |
1921 multipleSelectOk ifTrue:[ |
1923 multipleSelectOk ifTrue:[ |
1922 self sensor ctrlDown ifTrue:[ |
1924 sensor ctrlDown ifTrue:[ |
1923 selectedColIndex ~~ 0 ifTrue:[ |
1925 selectedColIndex ~~ 0 ifTrue:[ |
1924 colNr := 0 |
1926 colNr := 0 |
1925 ] ifFalse:[ |
1927 ] ifFalse:[ |
1926 (sz := self numberOfSelections == 0) ifFalse:[ |
1928 (sz := self numberOfSelections == 0) ifFalse:[ |
1927 (self isInSelection:rowNr) ifTrue:[ |
1929 (self isInSelection:rowNr) ifTrue:[ |
1928 sz == 1 ifTrue:[ |
1930 sz == 1 ifTrue:[ |
1929 self selectColIndex:0 rowIndex:nil. |
1931 self selectColIndex:0 rowIndex:nil. |
1930 ^ self sensor flushMotionEventsFor:self. |
1932 sensor flushMotionEventsFor:self. |
|
1933 ^ self |
1931 ]. |
1934 ]. |
1932 selectedRowIndex remove:rowNr. |
1935 selectedRowIndex remove:rowNr. |
1933 ] ifFalse:[ |
1936 ] ifFalse:[ |
1934 selectedRowIndex add:rowNr |
1937 selectedRowIndex add:rowNr |
1935 ]. |
1938 ]. |
1936 self invalidateRowAt:rowNr. |
1939 self invalidateRowAt:rowNr. |
1937 self selectionChanged. |
1940 self selectionChanged. |
1938 ^ self sensor flushMotionEventsFor:self. |
1941 sensor flushMotionEventsFor:self. |
|
1942 ^ self |
1939 ] |
1943 ] |
1940 ] |
1944 ] |
1941 ] ifFalse:[ |
1945 ] ifFalse:[ |
1942 ( selectedColIndex == 0 |
1946 ( selectedColIndex == 0 |
1943 and:[(first := self firstIndexSelected) ~~ 0 |
1947 and:[(first := self firstIndexSelected) ~~ 0 |
1944 and:[self sensor shiftDown]] |
1948 and:[sensor shiftDown]] |
1945 ) ifTrue:[|step list| |
1949 ) ifTrue:[|step list| |
1946 list := OrderedCollection new. |
1950 list := OrderedCollection new. |
1947 step := first < rowNr ifTrue:[1] ifFalse:[-1]. |
1951 step := first < rowNr ifTrue:[1] ifFalse:[-1]. |
1948 first to:rowNr by:step do:[:i|list add:i]. |
1952 first to:rowNr by:step do:[:i|list add:i]. |
1949 self selectedRowIndex:list. |
1953 self selectedRowIndex:list. |
2083 keyPress:aKey x:x y:y |
2084 keyPress:aKey x:x y:y |
2084 "a key was pressed - handle page-keys here |
2085 "a key was pressed - handle page-keys here |
2085 " |
2086 " |
2086 <resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown |
2087 <resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown |
2087 #BeginOfText #EndOfText #ScrollUp #ScrollDown |
2088 #BeginOfText #EndOfText #ScrollUp #ScrollDown |
2088 #CursorUp #CursorDown #CursorRight #CursorLeft)> |
2089 #CursorUp #CursorDown #CursorRight #CursorLeft #SelectAll)> |
2089 |
2090 |
2090 |sensor maxColNr selRowNr selColNr key column isTab listSize hasSelectables| |
2091 |sensor maxColNr selRowNr selColNr key column isTab listSize hasSelectables| |
2091 |
2092 |
2092 self isEnabled ifFalse:[^ self]. |
2093 self isEnabled ifFalse:[^ self]. |
2093 |
2094 |
2097 (listSize := list size) == 0 ifTrue:[ |
2098 (listSize := list size) == 0 ifTrue:[ |
2098 ^ super keyPress:aKey x:x y:y |
2099 ^ super keyPress:aKey x:x y:y |
2099 ]. |
2100 ]. |
2100 aKey isCharacter ifTrue:[ |
2101 aKey isCharacter ifTrue:[ |
2101 ^ self characterPress:aKey x:x y:y |
2102 ^ self characterPress:aKey x:x y:y |
|
2103 ]. |
|
2104 |
|
2105 (aKey == #SelectAll) ifTrue:[ |
|
2106 multipleSelectOk ifTrue:[ |
|
2107 self selectAllRows. |
|
2108 ]. |
|
2109 ^ self |
2102 ]. |
2110 ]. |
2103 |
2111 |
2104 aKey == #PreviousPage ifTrue:[^ self pageUp]. |
2112 aKey == #PreviousPage ifTrue:[^ self pageUp]. |
2105 aKey == #NextPage ifTrue:[^ self pageDown]. |
2113 aKey == #NextPage ifTrue:[^ self pageDown]. |
2106 aKey == #HalfPageUp ifTrue:[^ self halfPageUp]. |
2114 aKey == #HalfPageUp ifTrue:[^ self halfPageUp]. |
3129 ^ selectedRowIndex ~~ 0 ifTrue:[1] ifFalse:[0] |
3134 ^ selectedRowIndex ~~ 0 ifTrue:[1] ifFalse:[0] |
3130 ]. |
3135 ]. |
3131 ^ selectedRowIndex size |
3136 ^ selectedRowIndex size |
3132 ! |
3137 ! |
3133 |
3138 |
|
3139 selectAllRows |
|
3140 1 to:list size do:[:eachRowNr | |
|
3141 selectedRowIndex add:eachRowNr. |
|
3142 self invalidateRowAt:eachRowNr. |
|
3143 ]. |
|
3144 self selectionChanged. |
|
3145 ! |
|
3146 |
3134 selectColIndex:aColNr rowIndex:aRowNr |
3147 selectColIndex:aColNr rowIndex:aRowNr |
3135 "change selection with notification |
3148 "change selection with notification |
3136 " |
3149 " |
3137 |oC oR| |
3150 |oC oR| |
3138 |
3151 |