Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7d11cfa4
Commit
7d11cfa4
authored
Sep 04, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1056 from abarth/event_ordering
Events should bubble up the tree
parents
3f217243
f5102d11
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
14 deletions
+52
-14
hit_test.dart
packages/flutter/lib/base/hit_test.dart
+5
-6
sky_binding.dart
packages/flutter/lib/src/rendering/sky_binding.dart
+2
-2
view.dart
packages/flutter/lib/src/rendering/view.dart
+2
-5
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+1
-1
listener_test.dart
packages/unit/test/widget/listener_test.dart
+42
-0
No files found.
packages/flutter/lib/base/hit_test.dart
View file @
7d11cfa4
...
...
@@ -52,17 +52,16 @@ class HitTestResult {
/// The list of [HitTestEntry] objects recorded during the hit test.
///
/// The first entry in the path is the least specific, typically the one at
/// the root of tree being hit tested. Event propagation starts with the most
/// specific (i.e., last) entry and proceeds in reverse order through the
/// path.
/// The first entry in the path is the most specific, typically the one at
/// the leaf of tree being hit tested. Event propagation starts with the most
/// specific (i.e., first) entry and proceeds in order through the path.
final
List
<
HitTestEntry
>
path
;
/// Add a [HitTestEntry] to the path.
///
/// The new entry is added at the end of the path, which means entries should
/// be added in order from
last specific to mo
st specific, typically during a
///
down
ward walk in the tree being hit tested.
/// be added in order from
most specific to lea
st specific, typically during a
///
up
ward walk in the tree being hit tested.
void
add
(
HitTestEntry
entry
)
{
path
.
add
(
entry
);
}
...
...
packages/flutter/lib/src/rendering/sky_binding.dart
View file @
7d11cfa4
...
...
@@ -136,15 +136,15 @@ class SkyBinding extends HitTestTarget {
HitTestResult
hitTest
(
Point
position
)
{
HitTestResult
result
=
new
HitTestResult
();
result
.
add
(
new
BindingHitTestEntry
(
this
,
result
));
_renderView
.
hitTest
(
result
,
position:
position
);
result
.
add
(
new
BindingHitTestEntry
(
this
,
result
));
return
result
;
}
EventDisposition
dispatchEvent
(
sky
.
Event
event
,
HitTestResult
result
)
{
assert
(
result
!=
null
);
EventDisposition
disposition
=
EventDisposition
.
ignored
;
for
(
HitTestEntry
entry
in
result
.
path
.
reversed
)
{
for
(
HitTestEntry
entry
in
result
.
path
)
{
EventDisposition
entryDisposition
=
entry
.
target
.
handleEvent
(
event
,
entry
);
if
(
entryDisposition
==
EventDisposition
.
consumed
)
return
EventDisposition
.
consumed
;
...
...
packages/flutter/lib/src/rendering/view.dart
View file @
7d11cfa4
...
...
@@ -81,11 +81,8 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
}
bool
hitTest
(
HitTestResult
result
,
{
Point
position
})
{
if
(
child
!=
null
)
{
Rect
childBounds
=
Point
.
origin
&
child
.
size
;
if
(
childBounds
.
contains
(
position
))
child
.
hitTest
(
result
,
position:
position
);
}
if
(
child
!=
null
)
child
.
hitTest
(
result
,
position:
position
);
result
.
add
(
new
HitTestEntry
(
this
));
return
true
;
}
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
7d11cfa4
...
...
@@ -1366,7 +1366,7 @@ class WidgetSkyBinding extends SkyBinding {
EventDisposition
handleEvent
(
sky
.
Event
event
,
BindingHitTestEntry
entry
)
{
EventDisposition
disposition
=
EventDisposition
.
ignored
;
for
(
HitTestEntry
entry
in
entry
.
result
.
path
.
reversed
)
{
for
(
HitTestEntry
entry
in
entry
.
result
.
path
)
{
if
(
entry
.
target
is
!
RenderObject
)
continue
;
for
(
Widget
target
in
RenderObjectWrapper
.
getWidgetsForRenderObject
(
entry
.
target
))
{
...
...
packages/unit/test/widget/listener_test.dart
0 → 100644
View file @
7d11cfa4
import
'package:sky/widgets.dart'
;
import
'package:test/test.dart'
;
import
'widget_tester.dart'
;
void
main
(
)
{
test
(
'Events bubble up the tree'
,
()
{
WidgetTester
tester
=
new
WidgetTester
();
List
<
String
>
log
=
new
List
<
String
>();
tester
.
pumpFrame
(()
{
return
new
Listener
(
onPointerDown:
(
_
)
{
log
.
add
(
'top'
);
},
child:
new
Listener
(
onPointerDown:
(
_
)
{
log
.
add
(
'middle'
);
},
child:
new
DecoratedBox
(
decoration:
const
BoxDecoration
(),
child:
new
Listener
(
onPointerDown:
(
_
)
{
log
.
add
(
'bottom'
);
},
child:
new
Text
(
'X'
)
)
)
)
);
});
tester
.
tap
(
tester
.
findText
(
'X'
));
expect
(
log
,
equals
([
'bottom'
,
'middle'
,
'top'
,
]));
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment