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
0f70464e
Commit
0f70464e
authored
Apr 12, 2016
by
Jason Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Treat pointer cancel events similarly to pointer up events (#3242)
parent
c49d291f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
2 deletions
+76
-2
binding.dart
packages/flutter/lib/src/gestures/binding.dart
+2
-2
gesture_binding_test.dart
packages/flutter/test/gestures/gesture_binding_test.dart
+74
-0
No files found.
packages/flutter/lib/src/gestures/binding.dart
View file @
0f70464e
...
...
@@ -61,14 +61,14 @@ abstract class Gesturer extends BindingBase implements HitTestTarget, HitTestabl
HitTestResult
result
=
new
HitTestResult
();
hitTest
(
result
,
event
.
position
);
_hitTests
[
event
.
pointer
]
=
result
;
}
else
if
(
event
is
!
PointerUpEvent
)
{
}
else
if
(
event
is
!
PointerUpEvent
&&
event
is
!
PointerCancelEvent
)
{
assert
(
event
.
down
==
_hitTests
.
containsKey
(
event
.
pointer
));
if
(!
event
.
down
)
return
;
// we currently ignore add, remove, and hover move events
}
assert
(
_hitTests
[
event
.
pointer
]
!=
null
);
dispatchEvent
(
event
,
_hitTests
[
event
.
pointer
]);
if
(
event
is
PointerUpEvent
)
{
if
(
event
is
PointerUpEvent
||
event
is
PointerCancelEvent
)
{
assert
(
_hitTests
.
containsKey
(
event
.
pointer
));
_hitTests
.
remove
(
event
.
pointer
);
}
...
...
packages/flutter/test/gestures/gesture_binding_test.dart
0 → 100644
View file @
0f70464e
// Copyright 2016 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
'dart:ui'
as
ui
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/services.dart'
;
import
'package:mojo/bindings.dart'
as
mojo_bindings
;
import
'package:sky_services/pointer/pointer.mojom.dart'
;
import
'package:test/test.dart'
;
typedef
void
HandleEventCallback
(
PointerEvent
event
);
class
TestGestureFlutterBinding
extends
BindingBase
with
Gesturer
{
HandleEventCallback
callback
;
@override
void
handleEvent
(
PointerEvent
event
,
HitTestEntry
entry
)
{
if
(
callback
!=
null
)
callback
(
event
);
super
.
handleEvent
(
event
,
entry
);
}
}
TestGestureFlutterBinding
_binding
=
new
TestGestureFlutterBinding
();
void
ensureTestGesturer
(
)
{
if
(
_binding
==
null
)
_binding
=
new
TestGestureFlutterBinding
();
assert
(
Gesturer
.
instance
!=
null
);
}
void
main
(
)
{
setUp
(
ensureTestGesturer
);
test
(
'Pointer tap events'
,
()
{
mojo_bindings
.
Encoder
encoder
=
new
mojo_bindings
.
Encoder
();
PointerPacket
packet
=
new
PointerPacket
();
packet
.
pointers
=
<
Pointer
>[
new
Pointer
(),
new
Pointer
()];
packet
.
pointers
[
0
].
type
=
PointerType
.
down
;
packet
.
pointers
[
0
].
kind
=
PointerKind
.
touch
;
packet
.
pointers
[
1
].
type
=
PointerType
.
up
;
packet
.
pointers
[
1
].
kind
=
PointerKind
.
touch
;
packet
.
encode
(
encoder
);
List
<
PointerEvent
>
events
=
<
PointerEvent
>[];
_binding
.
callback
=
(
PointerEvent
event
)
=>
events
.
add
(
event
);
ui
.
window
.
onPointerPacket
(
encoder
.
message
.
buffer
);
expect
(
events
[
0
].
runtimeType
,
equals
(
PointerDownEvent
));
expect
(
events
[
1
].
runtimeType
,
equals
(
PointerUpEvent
));
});
test
(
'Pointer cancel events'
,
()
{
mojo_bindings
.
Encoder
encoder
=
new
mojo_bindings
.
Encoder
();
PointerPacket
packet
=
new
PointerPacket
();
packet
.
pointers
=
<
Pointer
>[
new
Pointer
(),
new
Pointer
()];
packet
.
pointers
[
0
].
type
=
PointerType
.
down
;
packet
.
pointers
[
0
].
kind
=
PointerKind
.
touch
;
packet
.
pointers
[
1
].
type
=
PointerType
.
cancel
;
packet
.
pointers
[
1
].
kind
=
PointerKind
.
touch
;
packet
.
encode
(
encoder
);
List
<
PointerEvent
>
events
=
<
PointerEvent
>[];
_binding
.
callback
=
(
PointerEvent
event
)
=>
events
.
add
(
event
);
ui
.
window
.
onPointerPacket
(
encoder
.
message
.
buffer
);
expect
(
events
[
0
].
runtimeType
,
equals
(
PointerDownEvent
));
expect
(
events
[
1
].
runtimeType
,
equals
(
PointerCancelEvent
));
});
}
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