Commit a15b27d4 authored by Adam Barth's avatar Adam Barth

Remove support for onGestureFoo from Listener

Please use GestureDetector instead.
parent 699fa241
...@@ -663,102 +663,31 @@ typedef EventDisposition PointerEventListener(sky.PointerEvent e); ...@@ -663,102 +663,31 @@ typedef EventDisposition PointerEventListener(sky.PointerEvent e);
typedef EventDisposition EventListener(sky.Event e); typedef EventDisposition EventListener(sky.Event e);
class Listener extends TagNode { class Listener extends TagNode {
Listener({ Listener({
Key key, Key key,
Widget child, Widget child,
EventListener onWheel, PointerEventListener this.onPointerDown,
GestureEventListener onGestureFlingCancel, PointerEventListener this.onPointerMove,
GestureEventListener onGestureFlingStart, PointerEventListener this.onPointerUp,
GestureEventListener onGestureScrollStart, PointerEventListener this.onPointerCancel
GestureEventListener onGestureScrollUpdate, }) : super(key: key, child: child);
GestureEventListener onGestureLongPress,
GestureEventListener onGestureTap, final PointerEventListener onPointerDown;
GestureEventListener onGestureTapDown, final PointerEventListener onPointerMove;
GestureEventListener onGestureShowPress, final PointerEventListener onPointerUp;
PointerEventListener onPointerCancel, final PointerEventListener onPointerCancel;
PointerEventListener onPointerDown,
PointerEventListener onPointerMove, EventDisposition _handleEvent(sky.Event event) {
PointerEventListener onPointerUp, if (onPointerDown != null && event.type == 'pointerdown')
Map<String, EventListener> custom return onPointerDown(event);
}) : listeners = _createListeners( if (onPointerMove != null && event.type == 'pointermove')
onWheel: onWheel, return onPointerMove(event);
onGestureFlingCancel: onGestureFlingCancel, if (onPointerUp != null && event.type == 'pointerup')
onGestureFlingStart: onGestureFlingStart, return onPointerUp(event);
onGestureScrollUpdate: onGestureScrollUpdate, if (onPointerCancel != null && event.type == 'pointercancel')
onGestureScrollStart: onGestureScrollStart, return onPointerCancel(event);
onGestureTap: onGestureTap,
onGestureTapDown: onGestureTapDown,
onGestureLongPress: onGestureLongPress,
onGestureShowPress: onGestureShowPress,
onPointerCancel: onPointerCancel,
onPointerDown: onPointerDown,
onPointerMove: onPointerMove,
onPointerUp: onPointerUp,
custom: custom
),
super(key: key, child: child);
final Map<String, EventListener> listeners;
static Map<String, EventListener> _createListeners({
EventListener onWheel,
GestureEventListener onGestureFlingCancel,
GestureEventListener onGestureFlingStart,
GestureEventListener onGestureScrollStart,
GestureEventListener onGestureScrollUpdate,
GestureEventListener onGestureTap,
GestureEventListener onGestureTapDown,
GestureEventListener onGestureLongPress,
GestureEventListener onGestureShowPress,
PointerEventListener onPointerCancel,
PointerEventListener onPointerDown,
PointerEventListener onPointerMove,
PointerEventListener onPointerUp,
Map<String, EventListener> custom
}) {
var listeners = custom != null ?
new HashMap<String, EventListener>.from(custom) :
new HashMap<String, EventListener>();
if (onWheel != null)
listeners['wheel'] = onWheel;
if (onGestureFlingCancel != null)
listeners['gestureflingcancel'] = onGestureFlingCancel;
if (onGestureFlingStart != null)
listeners['gestureflingstart'] = onGestureFlingStart;
if (onGestureScrollStart != null)
listeners['gesturescrollstart'] = onGestureScrollStart;
if (onGestureScrollUpdate != null)
listeners['gesturescrollupdate'] = onGestureScrollUpdate;
if (onGestureTap != null)
listeners['gesturetap'] = onGestureTap;
if (onGestureTapDown != null)
listeners['gesturetapdown'] = onGestureTapDown;
if (onGestureLongPress != null)
listeners['gesturelongpress'] = onGestureLongPress;
if (onGestureShowPress != null)
listeners['gestureshowpress'] = onGestureShowPress;
if (onPointerCancel != null)
listeners['pointercancel'] = onPointerCancel;
if (onPointerDown != null)
listeners['pointerdown'] = onPointerDown;
if (onPointerMove != null)
listeners['pointermove'] = onPointerMove;
if (onPointerUp != null)
listeners['pointerup'] = onPointerUp;
return listeners;
}
EventDisposition _handleEvent(sky.Event e) {
EventListener listener = listeners[e.type];
if (listener != null) {
return listener(e);
}
return EventDisposition.ignored; return EventDisposition.ignored;
} }
} }
abstract class Component extends Widget { abstract class Component extends Widget {
......
...@@ -100,8 +100,7 @@ abstract class Scrollable extends StatefulComponent { ...@@ -100,8 +100,7 @@ abstract class Scrollable extends StatefulComponent {
onHorizontalDragEnd: _getDragEndHandler(ScrollDirection.horizontal), onHorizontalDragEnd: _getDragEndHandler(ScrollDirection.horizontal),
child: new Listener( child: new Listener(
child: buildContent(), child: buildContent(),
onPointerDown: _handlePointerDown, onPointerDown: _handlePointerDown
onWheel: _handleWheel
) )
); );
} }
...@@ -195,11 +194,6 @@ abstract class Scrollable extends StatefulComponent { ...@@ -195,11 +194,6 @@ abstract class Scrollable extends StatefulComponent {
} }
} }
EventDisposition _handleWheel(sky.WheelEvent event) {
scrollBy(-event.offsetY);
return EventDisposition.processed;
}
final List<ScrollListener> _listeners = new List<ScrollListener>(); final List<ScrollListener> _listeners = new List<ScrollListener>();
void addListener(ScrollListener listener) { void addListener(ScrollListener listener) {
_listeners.add(listener); _listeners.add(listener);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment