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
c94e4c41
Commit
c94e4c41
authored
Nov 11, 2015
by
Jason Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the raw examples to handle PointerPacket events
parent
b1435e29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
25 deletions
+33
-25
hello_world.dart
examples/raw/hello_world.dart
+21
-15
spinning_image.dart
examples/raw/spinning_image.dart
+12
-10
No files found.
examples/raw/hello_world.dart
View file @
c94e4c41
...
...
@@ -5,6 +5,10 @@
import
'dart:ui'
as
ui
;
import
'dart:typed_data'
;
import
'package:mojo/bindings.dart'
as
bindings
;
import
'package:mojo/core.dart'
as
core
;
import
'package:sky_services/pointer/pointer.mojom.dart'
;
ui
.
Color
color
;
ui
.
Picture
paint
(
ui
.
Rect
paintBounds
)
{
...
...
@@ -42,25 +46,26 @@ void beginFrame(Duration timeStamp) {
ui
.
window
.
render
(
scene
);
}
bool
handleEvent
(
ui
.
Event
event
)
{
if
(
event
.
type
==
'pointerdown'
)
{
color
=
new
ui
.
Color
.
fromARGB
(
255
,
0
,
0
,
255
);
ui
.
window
.
scheduleFrame
();
return
true
;
void
handleEvent
(
String
eventType
,
double
timeStamp
)
{
if
(
eventType
==
'back'
)
{
print
(
'Pressed back button.'
);
}
}
if
(
event
.
type
==
'pointerup'
)
{
color
=
new
ui
.
Color
.
fromARGB
(
255
,
0
,
255
,
0
);
ui
.
window
.
scheduleFrame
();
return
true
;
}
void
handlePointerPacket
(
ByteData
serializedPacket
)
{
bindings
.
Message
message
=
new
bindings
.
Message
(
serializedPacket
,
<
core
.
MojoHandle
>[]);
PointerPacket
packet
=
PointerPacket
.
deserialize
(
message
);
if
(
event
.
type
==
'back'
)
{
print
(
'Pressed back button.'
);
return
true
;
for
(
Pointer
pointer
in
packet
.
pointers
)
{
if
(
pointer
.
type
==
PointerType
.
DOWN
)
{
color
=
new
ui
.
Color
.
fromARGB
(
255
,
0
,
0
,
255
);
ui
.
window
.
scheduleFrame
();
}
else
if
(
pointer
.
type
==
PointerType
.
UP
)
{
color
=
new
ui
.
Color
.
fromARGB
(
255
,
0
,
255
,
0
);
ui
.
window
.
scheduleFrame
();
}
}
return
false
;
}
void
main
(
)
{
...
...
@@ -68,5 +73,6 @@ void main() {
color
=
new
ui
.
Color
.
fromARGB
(
255
,
0
,
255
,
0
);
ui
.
window
.
onBeginFrame
=
beginFrame
;
ui
.
window
.
onEvent
=
handleEvent
;
ui
.
window
.
onPointerPacket
=
handlePointerPacket
;
ui
.
window
.
scheduleFrame
();
}
examples/raw/spinning_image.dart
View file @
c94e4c41
...
...
@@ -7,6 +7,9 @@ import 'dart:ui' as ui;
import
'dart:typed_data'
;
import
'package:flutter/services.dart'
;
import
'package:mojo/bindings.dart'
as
bindings
;
import
'package:mojo/core.dart'
as
core
;
import
'package:sky_services/pointer/pointer.mojom.dart'
;
Duration
timeBase
=
null
;
...
...
@@ -78,21 +81,20 @@ void handleImageLoad(result) {
}
}
bool
handleEvent
(
ui
.
Event
even
t
)
{
if
(
event
.
type
==
"pointerdown"
)
{
return
true
;
}
void
handlePointerPacket
(
ByteData
serializedPacke
t
)
{
bindings
.
Message
message
=
new
bindings
.
Message
(
serializedPacket
,
<
core
.
MojoHandle
>[])
;
PointerPacket
packet
=
PointerPacket
.
deserialize
(
message
);
if
(
event
.
type
==
"pointerup"
)
{
imageCache
.
load
(
url2
).
first
.
then
(
handleImageLoad
);
return
true
;
for
(
Pointer
pointer
in
packet
.
pointers
)
{
if
(
pointer
.
type
==
PointerType
.
UP
)
{
imageCache
.
load
(
url2
).
first
.
then
(
handleImageLoad
);
}
}
return
false
;
}
void
main
(
)
{
imageCache
.
load
(
url1
).
first
.
then
(
handleImageLoad
);
ui
.
window
.
on
Event
=
handleEven
t
;
ui
.
window
.
on
PointerPacket
=
handlePointerPacke
t
;
ui
.
window
.
onBeginFrame
=
beginFrame
;
}
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