Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Commit 67a2551

Browse files
authored
Merge pull request #259 from Unity-Technologies/siyao/CopyPaste
native modify key
2 parents e3c760b + f4a3969 commit 67a2551

File tree

21 files changed

+63
-33
lines changed

21 files changed

+63
-33
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:5a97dbcf3cf5c60d397d8abe072ae9d06b550c87f0d174e15ad3677d20673348
3-
size 83590216
2+
oid sha256:ac05731242706bce2c77bddc2af4059f9016f8c16ac9b075b12ef7776cf6df01
3+
size 84195040
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:8487dbfc03fba05398a7bc7ad533db6c8d806f65e98fe4fabd71001d81bda53a
3-
size 76135084
2+
oid sha256:65a6663fd0c92155fed6869a2902e486f27593d836c93a769ea137a0d4c068a5
3+
size 76739172
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:3c5e203b4851fe4179cc507d47a78a9b003a115b03da1087169727f664c96925
3-
size 247980952
2+
oid sha256:45f5772380e27b4a127aca15f4af961cd6703d716360f87c76a7191fc746a090
3+
size 247578504
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:09525c0fd42d83918c858c807c284545f22300aad0c65fdb6cb563e72b367bd0
3-
size 21822056
2+
oid sha256:d1de13043564e2f2b384ec3aefe1e500e42281b9d67cebca131c54ae841a0c37
3+
size 21804000

com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:d5673cc1242cdfe6ff074332c2e9381e55df60b9814ddb5ac72c66063545f577
2+
oid sha256:52dda23bf8cccf4e80dd4851bafe11bffae6beec925b1112ffa17cdbf13637e5
33
size 11260928

com.unity.uiwidgets/Runtime/engine/UIWidgetsPanelWrapper.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,14 @@ public void OnPointerLeave() {
343343
}
344344

345345
public void OnKeyDown(Event e) {
346-
UIWidgetsPanel_onKey(ptr: _ptr, keyCode: e.keyCode, e.type == EventType.KeyDown);
346+
int modifier = 0;
347+
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
348+
modifier |= e.shift ? (1 << (int) FunctionKey.shift) : 0;
349+
modifier |= e.alt ? (1 << (int) FunctionKey.alt) : 0;
350+
modifier |= e.command ? (1 << (int) FunctionKey.command) : 0;
351+
modifier |= e.control ? (1 << (int) FunctionKey.control) : 0;
352+
#endif
353+
UIWidgetsPanel_onKey(ptr: _ptr, keyCode: e.keyCode, e.type == EventType.KeyDown, modifier);
347354
if (e.character != 0 || e.keyCode == KeyCode.Backspace) {
348355
PointerEventConverter.KeyEvent.Enqueue(new Event(other: e));
349356
// TODO: add on char
@@ -355,7 +362,7 @@ public void OnKeyDown(Event e) {
355362
static extern void UIWidgetsPanel_onChar(IntPtr ptr, char c);
356363

357364
[DllImport(dllName: NativeBindings.dllName)]
358-
static extern void UIWidgetsPanel_onKey(IntPtr ptr, KeyCode keyCode, bool isKeyDown);
365+
static extern void UIWidgetsPanel_onKey(IntPtr ptr, KeyCode keyCode, bool isKeyDown, int modifier);
359366

360367
[DllImport(dllName: NativeBindings.dllName)]
361368
static extern void UIWidgetsPanel_onMouseDown(IntPtr ptr, float x, float y, int button);

com.unity.uiwidgets/Runtime/gestures/converter.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,13 @@ public static IEnumerable<PointerEvent> expand(IEnumerable<PointerData> data, fl
200200
}else if (datum.change == PointerChange.kMouseUp) {
201201
keyBoardEvent.type = EventType.KeyUp;
202202
}
203-
204203
keyBoardEvent.keyCode = (KeyCode)datum.buttons;
205-
204+
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
205+
keyBoardEvent.shift = (datum.modifier & (1 << (int) FunctionKey.shift)) > 0;
206+
keyBoardEvent.alt = (datum.modifier & (1 << (int) FunctionKey.alt)) > 0;
207+
keyBoardEvent.command = (datum.modifier & (1 << (int) FunctionKey.command)) > 0;
208+
keyBoardEvent.control = (datum.modifier & (1 << (int) FunctionKey.control)) > 0;
209+
#endif
206210
RawKeyboard.instance._handleKeyEvent(keyBoardEvent);
207211
TextInput.OnGUI();
208212
}

com.unity.uiwidgets/Runtime/ui/hooks.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ internal static void _invoke3<A1, A2, A3>(Action<A1, A2, A3> callback, Zone zone
288288
}
289289
}
290290

291-
const int _kPointerDataFieldCount = 28;
291+
const int _kPointerDataFieldCount = 29;
292292

293293
static unsafe PointerDataPacket _unpackPointerDataPacket(byte* packet, int packetLength) {
294294
const int kStride = 8;
@@ -311,6 +311,7 @@ static unsafe PointerDataPacket _unpackPointerDataPacket(byte* packet, int packe
311311
physicalDeltaX: (float) *(double*) (packet + kStride * offset++),
312312
physicalDeltaY: (float) *(double*) (packet + kStride * offset++),
313313
buttons: (int) *(long*) (packet + kStride * offset++),
314+
modifier: (int) *(long*) (packet + kStride * offset++),
314315
obscured: *(long*) (packet + kStride * offset++) != 0,
315316
synthesized: *(long*) (packet + kStride * offset++) != 0,
316317
pressure: (float) *(double*) (packet + kStride * offset++),

com.unity.uiwidgets/Runtime/ui/pointer.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public enum PointerSignalKind {
2929
unknown,
3030
}
3131

32+
public enum FunctionKey {
33+
none = 0,
34+
shift = 1,
35+
alt = 2,
36+
command = 3,
37+
control = 4,
38+
}
39+
3240
public readonly struct PointerData {
3341
public PointerData(
3442
TimeSpan? timeStamp = null,
@@ -42,6 +50,7 @@ public PointerData(
4250
float physicalDeltaX = 0.0f,
4351
float physicalDeltaY = 0.0f,
4452
int buttons = 0,
53+
int modifier = 0,
4554
bool obscured = false,
4655
bool synthesized = false,
4756
float pressure = 0.0f,
@@ -70,6 +79,7 @@ public PointerData(
7079
this.physicalDeltaX = physicalDeltaX;
7180
this.physicalDeltaY = physicalDeltaY;
7281
this.buttons = buttons;
82+
this.modifier = modifier;
7383
this.obscured = obscured;
7484
this.synthesized = synthesized;
7585
this.pressure = pressure;
@@ -100,6 +110,7 @@ public PointerData(
100110
public readonly float physicalDeltaX;
101111
public readonly float physicalDeltaY;
102112
public readonly int buttons;
113+
public readonly int modifier;
103114
public readonly bool obscured;
104115
public readonly bool synthesized;
105116
public readonly float pressure;

0 commit comments

Comments
 (0)