mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This patch removes the mutable API to event handling (Nodes no longer have a events object with which to add listeners). Instead, a new (non-Render) Node is introduced: EventTarget. This node represents a location in the Effen tree which can handle events as they bubble. Note that this also changes the implementation to use event delegation (one set of listeners at the sky.document level) rather than direct listeners on leaf nodes. R=abarth@chromium.org Review URL: https://codereview.chromium.org/1019633004
39 lines
794 B
Dart
39 lines
794 B
Dart
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import '../fn.dart';
|
|
|
|
abstract class ButtonBase extends Component {
|
|
bool highlight = false;
|
|
|
|
ButtonBase({ Object key }) : super(key: key);
|
|
|
|
Node buildContent();
|
|
|
|
Node build() {
|
|
return new EventTarget(
|
|
buildContent(),
|
|
onPointerDown: _handlePointerDown,
|
|
onPointerUp: _handlePointerUp,
|
|
onPointerCancel: _handlePointerCancel
|
|
);
|
|
}
|
|
|
|
void _handlePointerDown(_) {
|
|
setState(() {
|
|
highlight = true;
|
|
});
|
|
}
|
|
void _handlePointerUp(_) {
|
|
setState(() {
|
|
highlight = false;
|
|
});
|
|
}
|
|
void _handlePointerCancel(_) {
|
|
setState(() {
|
|
highlight = false;
|
|
});
|
|
}
|
|
}
|