回答編集履歴
1
見直しキャンペーン中
test
CHANGED
@@ -1,91 +1,46 @@
|
|
1
|
-
`BackSpace`を送るといいながら`Key.Back`がどこにもなくないですか?(まあリンク先が不親切なんですが^^;
|
1
|
+
`BackSpace`を送るといいながら、`Key.Back`がどこにもなくないですか?(まあリンク先が不親切なんですが^^;
|
2
|
-
|
3
|
-
|
4
2
|
|
5
3
|
このあたりは詳しくありませんが、`Key.Back`を送れば何となく動いてる気はします。
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
```
|
5
|
+
```cs
|
10
|
-
|
11
6
|
using System.Windows;
|
12
|
-
|
13
7
|
using System.Windows.Controls;
|
14
|
-
|
15
8
|
using System.Windows.Input;
|
16
9
|
|
17
|
-
|
18
|
-
|
19
10
|
namespace Questions306813
|
20
|
-
|
21
11
|
{
|
22
|
-
|
23
12
|
public partial class MainWindow : Window
|
24
|
-
|
25
13
|
{
|
26
|
-
|
27
14
|
private readonly int MaxLine = 6;
|
28
|
-
|
29
|
-
|
30
15
|
|
31
16
|
public MainWindow() => InitializeComponent();
|
32
17
|
|
33
|
-
|
34
|
-
|
35
18
|
private void TextBoxKeyDown(object sender, KeyEventArgs e)
|
36
|
-
|
37
19
|
{
|
38
|
-
|
39
20
|
if (TextBox.LineCount == MaxLine)
|
40
|
-
|
41
21
|
{
|
42
|
-
|
43
22
|
if (e.Key == Key.Enter) e.Handled = true;
|
44
|
-
|
45
23
|
}
|
46
|
-
|
47
24
|
else if (TextBox.LineCount > MaxLine)
|
48
|
-
|
49
25
|
{
|
50
|
-
|
51
26
|
Send(Key.Back);
|
52
|
-
|
53
27
|
}
|
54
|
-
|
55
28
|
}
|
56
29
|
|
57
|
-
|
58
|
-
|
59
30
|
private void Send(Key key)
|
60
|
-
|
61
31
|
{
|
62
|
-
|
63
32
|
if (Keyboard.PrimaryDevice != null)
|
64
|
-
|
65
33
|
{
|
66
|
-
|
67
34
|
if (Keyboard.PrimaryDevice.ActiveSource != null)
|
68
|
-
|
69
35
|
{
|
70
|
-
|
71
36
|
var e1 = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, key)
|
72
|
-
|
73
37
|
{
|
74
|
-
|
75
38
|
RoutedEvent = KeyDownEvent,
|
76
|
-
|
77
39
|
};
|
78
|
-
|
79
40
|
InputManager.Current.ProcessInput(e1);
|
80
|
-
|
81
41
|
}
|
82
|
-
|
83
42
|
}
|
84
|
-
|
85
43
|
}
|
86
|
-
|
87
44
|
}
|
88
|
-
|
89
45
|
}
|
90
|
-
|
91
46
|
```
|