回答編集履歴

1

InkCanvas由来の問題として回答内容を丸ごと修正

2019/09/04 07:28

投稿

tor4kichi
tor4kichi

スコア763

test CHANGED
@@ -1,163 +1,7 @@
1
- > まず基礎的な用語の整理して、PointerMovedなどは`イベント`と呼び、イベント処理する関数は`イベントハンドラー`と呼びます。
1
+ InkCanvas同時にPointerMovedなど入力イベントを扱う場合は`InkCanvas.InkPresenter.UnprocessedInput`を通じて入力にアクセス出来るようです。
2
2
 
3
3
 
4
4
 
5
- ポインター系イベトは`Grid`など`Control`を継承していいレイアウト系オブジェクトでも、「`Background`を`Null`以外(`Transparent`でも可)に設定」し上で、「`IsHitTestVisible="True"` にする」ことで全体にポインタのインタラクションが発生するようになります。
5
+ UWP アプリで操作と Windows Ink(高度処理のための入力のススルー
6
6
 
7
-
8
-
9
- また蛇足ですが、イベントハンドラーは`Grid`に対して異なるイベントであれば一括で設定できます。ですので今回の場合`Grid`をいくつもネスト(入れ子)して配置する必要はありません。
10
-
11
-
12
-
13
- `Canvas_PointerMoved`と`Grid_PointerMoved`は同じタイミングで呼ばれるため、処理を統合したほうがいいかと思います。
14
-
15
-
16
-
17
- ```
18
-
19
- <Page
20
-
21
- x:Class="UWPApp1.BlankPage1"
22
-
23
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
24
-
25
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
26
-
27
- xmlns:local="using:UWPApp1"
28
-
29
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
30
-
31
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
32
-
33
- mc:Ignorable="d"
34
-
35
- Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
36
-
37
-
38
-
39
- <Grid PointerMoved="Grid_PointerMoved"
40
-
41
- PointerReleased="Canvas_PointerReleased"
42
-
43
- PointerPressed="Canvas_PointerPressed"
44
-
45
- Background="White"
46
-
47
- IsHitTestVisible="True"
48
-
49
- >
50
-
51
- <Grid>
52
-
53
- <Grid.RowDefinitions>
54
-
55
- <RowDefinition Height="Auto"/>
56
-
57
- <RowDefinition Height="*"/>
58
-
59
- </Grid.RowDefinitions>
60
-
61
- <StackPanel x:Name="HeaderPanel"
62
-
63
- Orientation="Horizontal"
64
-
65
- Grid.Row="0">
66
-
67
- <TextBlock x:Name="Header"
68
-
69
- Style="{ThemeResource HeaderTextBlockStyle}"
70
-
71
- Margin="10,0,0,0" SelectionChanged="Header_SelectionChanged" >
72
-
73
- <Run Text="描画してください"/>
74
-
75
- <LineBreak/>
76
-
77
- <Run/>
78
-
79
- </TextBlock>
80
-
81
- <TextBlock x:Name="text_position" TextWrapping="Wrap" Text="TextBlock" FontSize="24"/>
82
-
83
- <TextBlock x:Name="text_isPointerOn" TextWrapping="Wrap" Text="TextBlock" FontSize="24"/>
84
-
85
- </StackPanel>
86
-
87
-
88
-
89
- <Grid x:Name="drawingCanvas" Grid.Row="1" FocusVisualPrimaryBrush="Black">
90
-
91
- <Grid.ColumnDefinitions>
92
-
93
- <ColumnDefinition Width="0*"/>
94
-
95
- <ColumnDefinition/>
96
-
97
- </Grid.ColumnDefinitions>
98
-
99
- <Grid.FocusVisualSecondaryBrush>
100
-
101
- <AcrylicBrush/>
102
-
103
- </Grid.FocusVisualSecondaryBrush>
104
-
105
-
106
-
107
- <!-- The canvas where we render the replacement text and shapes. -->
108
-
109
- <!-- The canvas for ink input. -->
110
-
111
- <InkCanvas x:Name="inkCanvas" Grid.ColumnSpan="2" Margin="6,0,-6,0" FocusVisualPrimaryBrush="{x:Null}" FocusVisualSecondaryBrush="{x:Null}" Opacity="0.5" />
112
-
113
-
114
-
115
- <!-- The canvas where we render the replacement text and shapes. -->
116
-
117
- <Canvas x:Name="recognitionCanvas" Grid.ColumnSpan="2" />
118
-
119
- <!-- The canvas for ink input. -->
120
-
121
- </Grid>
122
-
123
- </Grid>
124
-
125
-
126
-
127
- <Canvas HorizontalAlignment="Left" VerticalAlignment="Top">
128
-
129
- <Ellipse
130
-
131
- Stroke="#FF044B0A" FocusVisualPrimaryBrush="{x:Null}" FocusVisualSecondaryBrush="{x:Null}" Margin="132,189,-132,-189"
132
-
133
- Height="187" Width="189" RenderTransformOrigin="0.5,0.5" Visibility="Visible" RequestedTheme="Light" Canvas.Left="99" Canvas.Top="162" UseLayoutRounding="False" d:LayoutRounding="Auto"
134
-
135
- >
136
-
137
- <Ellipse.RenderTransform>
138
-
139
- <CompositeTransform Rotation="-0.481"/>
140
-
141
- </Ellipse.RenderTransform>
142
-
143
- </Ellipse>
144
-
145
- </Canvas>
146
-
147
- <Button Content="Button" Margin="118,63,0,0" VerticalAlignment="Top" RenderTransformOrigin="-3.172,0.297" Click="Button_Click"/>
148
-
149
- <TextBlock HorizontalAlignment="Left" Margin="121,91,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="24">
150
-
151
- <Run Text="戻るボタン"/>
152
-
153
- <LineBreak/>
154
-
155
- <Run/>
156
-
157
- </TextBlock>
158
-
159
- </Grid>
160
-
161
- </Page>
162
-
163
- ```
7
+ [https://docs.microsoft.com/ja-jp/windows/uwp/design/input/pen-and-stylus-interactions#pass-through-input-for-advanced-processing](https://docs.microsoft.com/ja-jp/windows/uwp/design/input/pen-and-stylus-interactions#pass-through-input-for-advanced-processing)