update disp_engine_t and panel key code to web-based string instead of int64.
This commit is contained in:
parent
aa85e54a44
commit
0e0adaa98f
@ -1,4 +1,4 @@
|
|||||||
using Hi.Disp;
|
using Hi.Disp;
|
||||||
using Hi.Native;
|
using Hi.Native;
|
||||||
using Hi.PanelModels;
|
using Hi.PanelModels;
|
||||||
using System;
|
using System;
|
||||||
@ -297,12 +297,52 @@ namespace Hi.WpfPlus.Disp
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Keyboard_Events
|
#region Keyboard_Events
|
||||||
|
/// <summary>
|
||||||
|
/// Convert WPF Key to W3C KeyboardEvent.key string.
|
||||||
|
/// </summary>
|
||||||
|
static string WpfKeyToW3C(Key key) => key switch
|
||||||
|
{
|
||||||
|
Key.Home => "Home",
|
||||||
|
Key.End => "End",
|
||||||
|
Key.PageUp => "PageUp",
|
||||||
|
Key.PageDown => "PageDown",
|
||||||
|
Key.Left => "ArrowLeft",
|
||||||
|
Key.Right => "ArrowRight",
|
||||||
|
Key.Up => "ArrowUp",
|
||||||
|
Key.Down => "ArrowDown",
|
||||||
|
Key.LeftShift or Key.RightShift => "Shift",
|
||||||
|
Key.LeftCtrl or Key.RightCtrl => "Control",
|
||||||
|
Key.LeftAlt or Key.RightAlt => "Alt",
|
||||||
|
Key.Return => "Enter",
|
||||||
|
Key.Escape => "Escape",
|
||||||
|
Key.Back => "Backspace",
|
||||||
|
Key.Tab => "Tab",
|
||||||
|
Key.Delete => "Delete",
|
||||||
|
Key.Insert => "Insert",
|
||||||
|
Key.Space => " ",
|
||||||
|
Key.F1 => "F1",
|
||||||
|
Key.F2 => "F2",
|
||||||
|
Key.F3 => "F3",
|
||||||
|
Key.F4 => "F4",
|
||||||
|
Key.F5 => "F5",
|
||||||
|
Key.F6 => "F6",
|
||||||
|
Key.F7 => "F7",
|
||||||
|
Key.F8 => "F8",
|
||||||
|
Key.F9 => "F9",
|
||||||
|
Key.F10 => "F10",
|
||||||
|
Key.F11 => "F11",
|
||||||
|
Key.F12 => "F12",
|
||||||
|
>= Key.A and <= Key.Z => ((char)('a' + (key - Key.A))).ToString(),
|
||||||
|
>= Key.D0 and <= Key.D9 => ((char)('0' + (key - Key.D0))).ToString(),
|
||||||
|
_ => "Unidentified"
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the key up event
|
/// Handles the key up event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void RenderingCanvas_KeyUp(object sender, KeyEventArgs e)
|
private void RenderingCanvas_KeyUp(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
DispEngine.KeyUp((long)e.Key);
|
DispEngine.KeyUp(WpfKeyToW3C(e.Key));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -310,27 +350,23 @@ namespace Hi.WpfPlus.Disp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void RenderingCanvas_KeyDown(object sender, KeyEventArgs e)
|
private void RenderingCanvas_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
DispEngine.KeyDown((long)e.Key);
|
string key = WpfKeyToW3C(e.Key);
|
||||||
|
DispEngine.KeyDown(key);
|
||||||
// Map specific keys for view transformation
|
|
||||||
long key = (long)e.Key;
|
|
||||||
if (key == (long)Key.RightShift)
|
|
||||||
key = (long)Key.LeftShift;
|
|
||||||
|
|
||||||
DispEngine.KeyDownTransform(key, new key_table__transform_view_by_key_pressing_t()
|
DispEngine.KeyDownTransform(key, new key_table__transform_view_by_key_pressing_t()
|
||||||
{
|
{
|
||||||
HOME = (long)Key.Home,
|
HOME = "Home",
|
||||||
PAGE_UP = (long)Key.PageUp,
|
PAGE_UP = "PageUp",
|
||||||
PAGE_DOWN = (long)Key.PageDown,
|
PAGE_DOWN = "PageDown",
|
||||||
F1 = (long)Key.F1,
|
F1 = "F1",
|
||||||
F2 = (long)Key.F2,
|
F2 = "F2",
|
||||||
F3 = (long)Key.F3,
|
F3 = "F3",
|
||||||
F4 = (long)Key.F4,
|
F4 = "F4",
|
||||||
SHIFT = (long)Key.LeftShift,
|
SHIFT = "Shift",
|
||||||
ARROW_LEFT = (long)Key.Left,
|
ARROW_LEFT = "ArrowLeft",
|
||||||
ARROW_RIGHT = (long)Key.Right,
|
ARROW_RIGHT = "ArrowRight",
|
||||||
ARROW_DOWN = (long)Key.Down,
|
ARROW_DOWN = "ArrowDown",
|
||||||
ARROW_UP = (long)Key.Up
|
ARROW_UP = "ArrowUp"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user