diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..c30483a749 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# All Files +[*] +charset = utf-8 +end_of_line = crlf +indent_style = space +indent_size = 4 +insert_final_newline = false +trim_trailing_whitespace = true + +# Solution Files +[*.sln] +indent_style = tab + +# Markdown Files +[*.md] +trim_trailing_whitespace = false + +# Web Files +[*.{htm,html,js,ts,css,scss,less}] +insert_final_newline = true +indent_size = 2 \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Rendering/EventForDotNet.ts b/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Rendering/EventForDotNet.ts index 8d273fd045..8bd1453dd5 100644 --- a/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Rendering/EventForDotNet.ts +++ b/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Rendering/EventForDotNet.ts @@ -1,4 +1,4 @@ -export class EventForDotNet { +export class EventForDotNet { constructor(public readonly type: EventArgsType, public readonly data: TData) { } @@ -9,13 +9,13 @@ case 'change': { const targetIsCheckbox = isCheckbox(element); const newValue = targetIsCheckbox ? !!element['checked'] : element['value']; - return new EventForDotNet('change', { Type: event.type, Value: newValue }); + return new EventForDotNet('change', { type: event.type, value: newValue }); } case 'copy': case 'cut': case 'paste': - return new EventForDotNet('clipboard', { Type: event.type }); + return new EventForDotNet('clipboard', { type: event.type }); case 'drag': case 'dragend': @@ -24,21 +24,18 @@ case 'dragover': case 'dragstart': case 'drop': - return new EventForDotNet('drag', { Type: event.type }); - - case 'error': - return new EventForDotNet('error', { Type: event.type }); + return new EventForDotNet('drag', parseDragEvent(event)); case 'focus': case 'blur': case 'focusin': case 'focusout': - return new EventForDotNet('focus', { Type: event.type }); + return new EventForDotNet('focus', { type: event.type }); case 'keydown': case 'keyup': case 'keypress': - return new EventForDotNet('keyboard', { Type: event.type, Key: (event as any).key }); + return new EventForDotNet('keyboard', parseKeyboardEvent(event)); case 'contextmenu': case 'click': @@ -48,16 +45,24 @@ case 'mousedown': case 'mouseup': case 'dblclick': - return new EventForDotNet('mouse', { Type: event.type }); + return new EventForDotNet('mouse', parseMouseEvent(event)); + case 'loadstart': + case 'timeout': + case 'abort': + case 'load': + case 'loadend': + case 'error': case 'progress': - return new EventForDotNet('progress', { Type: event.type }); + return new EventForDotNet('progress', parseProgressEvent(event)); case 'touchcancel': case 'touchend': case 'touchmove': + case 'touchenter': + case 'touchleave': case 'touchstart': - return new EventForDotNet('touch', { Type: event.type }); + return new EventForDotNet('touch', parseTouchEvent(event)); case 'gotpointercapture': case 'lostpointercapture': @@ -69,18 +74,133 @@ case 'pointerout': case 'pointerover': case 'pointerup': - return new EventForDotNet('pointer', { Type: event.type }); + return new EventForDotNet('pointer', parsePointerEvent(event)); + case 'wheel': case 'mousewheel': - return new EventForDotNet('wheel', { Type: event.type }); - + return new EventForDotNet('wheel', parseWheelEvent(event)); default: - return new EventForDotNet('unknown', { Type: event.type }); + return new EventForDotNet('unknown', { type: event.type }); } } } +function parseDragEvent(event: any) { + return { + type: event.type, + detail: event.detail, + dataTransfer: event.dataTransfer, + screenX: event.screenX, + screenY: event.screenY, + clientX: event.clientX, + clientY: event.clientY, + button: event.button, + buttons: event.buttons, + ctrlKey: event.ctrlKey, + shiftKey: event.shiftKey, + altKey: event.altKey, + metaKey: event.metaKey + } +} + +function parseWheelEvent(event: WheelEvent) { + return { + ...parseMouseEvent(event), + deltaX: event.deltaX, + deltaY: event.deltaY, + deltaZ: event.deltaZ, + deltaMode: event.deltaMode + }; +} + +function parseProgressEvent(event: ProgressEvent) { + return { + type: event.type, + lengthComputable: event.lengthComputable, + loaded: event.loaded, + total: event.total + }; +} + +function parseTouchEvent(event: TouchEvent) { + + function parseTouch(touchList: TouchList) { + const touches: UITouchPoint[] = []; + + for (let i = 0; i < touchList.length; i++) { + const touch = touchList[i]; + touches.push({ + identifier: touch.identifier, + clientX: touch.clientX, + clientY: touch.clientY, + screenX: touch.screenX, + screenY: touch.screenY, + pageX: touch.pageX, + pageY: touch.pageY + }); + } + return touches; + } + + return { + type: event.type, + detail: event.detail, + touches: parseTouch(event.touches), + targetTouches: parseTouch(event.targetTouches), + changedTouches: parseTouch(event.changedTouches), + ctrlKey: event.ctrlKey, + shiftKey: event.shiftKey, + altKey: event.altKey, + metaKey: event.metaKey + }; +} + +function parseKeyboardEvent(event: KeyboardEvent) { + return { + type: event.type, + key: event.key, + code: event.code, + location: event.location, + repeat: event.repeat, + ctrlKey: event.ctrlKey, + shiftKey: event.shiftKey, + altKey: event.altKey, + metaKey: event.metaKey + }; +} + +function parsePointerEvent(event: PointerEvent) { + return { + ...parseMouseEvent(event), + pointerId: event.pointerId, + width: event.width, + height: event.height, + pressure: event.pressure, + tiltX: event.tiltX, + tiltY: event.tiltY, + pointerType: event.pointerType, + isPrimary: event.isPrimary + }; +} + +function parseMouseEvent(event: MouseEvent) { + return { + type: event.type, + detail: event.detail, + screenX: event.screenX, + screenY: event.screenY, + clientX: event.clientX, + clientY: event.clientY, + button: event.button, + buttons: event.buttons, + ctrlKey: event.ctrlKey, + shiftKey: event.shiftKey, + altKey: event.altKey, + metaKey: event.metaKey + }; +} + function isCheckbox(element: Element | null) { return element && element.tagName === 'INPUT' && element.getAttribute('type') === 'checkbox'; } @@ -90,40 +210,116 @@ function isCheckbox(element: Element | null) { type EventArgsType = 'change' | 'clipboard' | 'drag' | 'error' | 'focus' | 'keyboard' | 'mouse' | 'pointer' | 'progress' | 'touch' | 'unknown' | 'wheel'; export interface UIEventArgs { - Type: string; + type: string; } interface UIChangeEventArgs extends UIEventArgs { - Value: string | boolean; + value: string | boolean; } interface UIClipboardEventArgs extends UIEventArgs { } interface UIDragEventArgs extends UIEventArgs { + detail: number; + dataTransfer: UIDataTransfer; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + button: number; + buttons: number; + ctrlKey: boolean; + shiftKey: boolean; + altKey: boolean; + metaKey: boolean; } -interface UIErrorEventArgs extends UIEventArgs { +interface UIDataTransfer { + dropEffect: string; + effectAllowed: string; + files: string[]; + items: UIDataTransferItem[]; + types: string[]; +} + +interface UIDataTransferItem { + kind: string; + type: string; +} + +interface UIErrorEventArgs extends UIProgressEventArgs { } interface UIFocusEventArgs extends UIEventArgs { } interface UIKeyboardEventArgs extends UIEventArgs { - Key: string; + key: string; + code: string; + location: number; + repeat: boolean; + ctrlKey: boolean; + shiftKey: boolean; + altKey: boolean; + metaKey: boolean; } interface UIMouseEventArgs extends UIEventArgs { + detail: number; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + button: number; + buttons: number; + ctrlKey: boolean; + shiftKey: boolean; + altKey: boolean; + metaKey: boolean; } interface UIPointerEventArgs extends UIMouseEventArgs { + pointerId: number; + width: number; + height: number; + pressure: number; + tiltX: number; + tiltY: number; + pointerType: string; + isPrimary: boolean; } interface UIProgressEventArgs extends UIEventArgs { + lengthComputable: boolean; + loaded: number; + total: number; } interface UITouchEventArgs extends UIEventArgs { + detail: number; + touches: UITouchPoint[]; + targetTouches: UITouchPoint[]; + changedTouches: UITouchPoint[]; + ctrlKey: boolean; + shiftKey: boolean; + altKey: boolean; + metaKey: boolean; } -interface UIWheelEventArgs extends UIEventArgs { +interface UITouchPoint { + identifier: number; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; +} + +interface UIWheelEventArgs extends UIMouseEventArgs { + deltaX: number; + deltaY: number; + deltaZ: number; + deltaMode: number; } diff --git a/src/Microsoft.AspNetCore.Blazor/Components/EventHandlers.cs b/src/Microsoft.AspNetCore.Blazor/Components/EventHandlers.cs index 3e3c2f32c6..22f873fd8e 100644 --- a/src/Microsoft.AspNetCore.Blazor/Components/EventHandlers.cs +++ b/src/Microsoft.AspNetCore.Blazor/Components/EventHandlers.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -24,6 +24,7 @@ namespace Microsoft.AspNetCore.Blazor.Components [EventHandler("onmouseup", typeof(UIMouseEventArgs))] [EventHandler("onclick", typeof(UIMouseEventArgs))] [EventHandler("ondblclick", typeof(UIMouseEventArgs))] + [EventHandler("onwheel", typeof(UIWheelEventArgs))] [EventHandler("onmousewheel", typeof(UIWheelEventArgs))] [EventHandler("oncontextmenu", typeof(UIMouseEventArgs))] @@ -64,6 +65,8 @@ namespace Microsoft.AspNetCore.Blazor.Components [EventHandler("ontouchend", typeof(UITouchEventArgs))] [EventHandler("ontouchmove", typeof(UITouchEventArgs))] [EventHandler("ontouchstart", typeof(UITouchEventArgs))] + [EventHandler("ontouchenter", typeof(UITouchEventArgs))] + [EventHandler("ontouchleave", typeof(UITouchEventArgs))] // Pointer events [EventHandler("gotpointercapture", typeof(UIPointerEventArgs))] @@ -96,14 +99,16 @@ namespace Microsoft.AspNetCore.Blazor.Components [EventHandler("onvolumechange", typeof(UIEventArgs))] [EventHandler("onwaiting", typeof(UIEventArgs))] - // Error events + // Progress events + [EventHandler("onloadstart", typeof(UIProgressEventArgs))] + [EventHandler("ontimeout", typeof(UIProgressEventArgs))] + [EventHandler("onabort", typeof(UIProgressEventArgs))] + [EventHandler("onload", typeof(UIProgressEventArgs))] + [EventHandler("onloadend", typeof(UIProgressEventArgs))] + [EventHandler("onprogress", typeof(UIProgressEventArgs))] [EventHandler("onerror", typeof(UIErrorEventArgs))] - // Progress events - [EventHandler("onprogress", typeof(UIProgressEventArgs))] - // General events - [EventHandler("onabort", typeof(UIEventArgs))] [EventHandler("onactivate", typeof(UIEventArgs))] [EventHandler("onbeforeactivate", typeof(UIEventArgs))] [EventHandler("onbeforedeactivate", typeof(UIEventArgs))] @@ -111,10 +116,8 @@ namespace Microsoft.AspNetCore.Blazor.Components [EventHandler("onended", typeof(UIEventArgs))] [EventHandler("onfullscreenchange", typeof(UIEventArgs))] [EventHandler("onfullscreenerror", typeof(UIEventArgs))] - [EventHandler("onload", typeof(UIEventArgs))] [EventHandler("onloadeddata", typeof(UIEventArgs))] [EventHandler("onloadedmetadata", typeof(UIEventArgs))] - [EventHandler("onloadstart", typeof(UIEventArgs))] [EventHandler("onpointerlockchange", typeof(UIEventArgs))] [EventHandler("onpointerlockerror", typeof(UIEventArgs))] [EventHandler("onreadystatechange", typeof(UIEventArgs))] diff --git a/src/Microsoft.AspNetCore.Blazor/UIEventArgs.cs b/src/Microsoft.AspNetCore.Blazor/UIEventArgs.cs index 200bb15d53..424ca133d8 100644 --- a/src/Microsoft.AspNetCore.Blazor/UIEventArgs.cs +++ b/src/Microsoft.AspNetCore.Blazor/UIEventArgs.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Microsoft.AspNetCore.Blazor @@ -38,12 +38,137 @@ namespace Microsoft.AspNetCore.Blazor /// public class UIDragEventArgs : UIEventArgs { + /// + /// A count of consecutive clicks that happened in a short amount of time, incremented by one. + /// + public float Detail { get; set; } + + /// + /// The data that underlies a drag-and-drop operation, known as the drag data store. + /// See . + /// + public DataTransfer DataTransfer { get; set; } + + /// + /// The X coordinate of the mouse pointer in global (screen) coordinates. + /// + public long ScreenX { get; set; } + + /// + /// The Y coordinate of the mouse pointer in global (screen) coordinates. + /// + public long ScreenY { get; set; } + + /// + /// The X coordinate of the mouse pointer in local (DOM content) coordinates. + /// + public long ClientX { get; set; } + + /// + /// The Y coordinate of the mouse pointer in local (DOM content) coordinates. + /// + public long ClientY { get; set; } + + /// + /// The button number that was pressed when the mouse event was fired: + /// Left button=0, + /// middle button=1 (if present), + /// right button=2. + /// For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left. + /// + public long Button { get; set; } + + /// + /// The buttons being pressed when the mouse event was fired: + /// Left button=1, + /// Right button=2, + /// Middle (wheel) button=4, + /// 4th button (typically, "Browser Back" button)=8, + /// 5th button (typically, "Browser Forward" button)=16. + /// If two or more buttons are pressed, returns the logical sum of the values. + /// E.g., if Left button and Right button are pressed, returns 3 (=1 | 2). + /// + public long Buttons { get; set; } + + /// + /// true if the control key was down when the event was fired. false otherwise. + /// + public bool CtrlKey { get; set; } + + /// + /// true if the shift key was down when the event was fired. false otherwise. + /// + public bool ShiftKey { get; set; } + + /// + /// true if the alt key was down when the event was fired. false otherwise. + /// + public bool AltKey { get; set; } + + /// + /// true if the meta key was down when the event was fired. false otherwise. + /// + public bool MetaKey { get; set; } + } + + /// + /// The object is used to hold the data that is being dragged during a drag and drop operation. + /// It may hold one or more , each of one or more data types. + /// For more information about drag and drop, see HTML Drag and Drop API. + /// + public class DataTransfer + { + /// + /// Gets the type of drag-and-drop operation currently selected or sets the operation to a new type. + /// The value must be none, copy, link or move. + /// + public string DropEffect { get; set; } + + /// + /// Provides all of the types of operations that are possible. + /// Must be one of none, copy, copyLink, copyMove, link, linkMove, move, all or uninitialized. + /// + public string EffectAllowed { get; set; } + + /// + /// Contains a list of all the local files available on the data transfer. + /// If the drag operation doesn't involve dragging files, this property is an empty list. + /// + public string[] Files { get; set; } + + /// + /// Gives a array which is a list of all of the drag data. + /// + public UIDataTransferItem[] Items { get; set; } + + /// + /// An array of giving the formats that were set in the dragstart event. + /// + public string[] Types { get; set; } + } + + /// + /// The object represents one drag data item. + /// During a drag operation, each drag event has a dataTransfer property which contains a list of drag data items. + /// Each item in the list is a object. + /// + public class UIDataTransferItem + { + /// + /// The kind of drag data item, string or file + /// + public string Kind { get; set; } + + /// + /// The drag data item's type, typically a MIME type + /// + public string Type { get; set; } } /// /// Supplies information about an error event that is being raised. /// - public class UIErrorEventArgs : UIEventArgs + public class UIErrorEventArgs : UIProgressEventArgs { } @@ -62,9 +187,48 @@ namespace Microsoft.AspNetCore.Blazor public class UIKeyboardEventArgs : UIEventArgs { /// - /// If applicable, gets or sets the key that produced the event. + /// The key value of the key represented by the event. + /// If the value has a printed representation, this attribute's value is the same as the char attribute. + /// Otherwise, it's one of the key value strings specified in 'Key values'. + /// If the key can't be identified, this is the string "Unidentified" /// public string Key { get; set; } + + /// + /// Holds a string that identifies the physical key being pressed. + /// The value is not affected by the current keyboard layout or modifier state, so a particular key will always return the same value. + /// + public string Code { get; set; } + + /// + /// The location of the key on the device. + /// + public float Location { get; set; } + + /// + /// true if a key has been depressed long enough to trigger key repetition, otherwise false. + /// + public bool Repeat { get; set; } + + /// + /// true if the control key was down when the event was fired. false otherwise. + /// + public bool CtrlKey { get; set; } + + /// + /// true if the shift key was down when the event was fired. false otherwise. + /// + public bool ShiftKey { get; set; } + + /// + /// true if the alt key was down when the event was fired. false otherwise. + /// + public bool AltKey { get; set; } + + /// + /// true if the meta key was down when the event was fired. false otherwise. + /// + public bool MetaKey { get; set; } } /// @@ -72,6 +236,71 @@ namespace Microsoft.AspNetCore.Blazor /// public class UIMouseEventArgs : UIEventArgs { + /// + /// A count of consecutive clicks that happened in a short amount of time, incremented by one. + /// + public float Detail { get; set; } + + /// + /// The X coordinate of the mouse pointer in global (screen) coordinates. + /// + public long ScreenX { get; set; } + + /// + /// The Y coordinate of the mouse pointer in global (screen) coordinates. + /// + public long ScreenY { get; set; } + + /// + /// The X coordinate of the mouse pointer in local (DOM content) coordinates. + /// + public long ClientX { get; set; } + + /// + /// The Y coordinate of the mouse pointer in local (DOM content) coordinates. + /// + public long ClientY { get; set; } + + /// + /// The button number that was pressed when the mouse event was fired: + /// Left button=0, + /// middle button=1 (if present), + /// right button=2. + /// For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left. + /// + public long Button { get; set; } + + /// + /// The buttons being pressed when the mouse event was fired: + /// Left button=1, + /// Right button=2, + /// Middle (wheel) button=4, + /// 4th button (typically, "Browser Back" button)=8, + /// 5th button (typically, "Browser Forward" button)=16. + /// If two or more buttons are pressed, returns the logical sum of the values. + /// E.g., if Left button and Right button are pressed, returns 3 (=1 | 2). + /// + public long Buttons { get; set; } + + /// + /// true if the control key was down when the event was fired. false otherwise. + /// + public bool CtrlKey { get; set; } + + /// + /// true if the shift key was down when the event was fired. false otherwise. + /// + public bool ShiftKey { get; set; } + + /// + /// true if the alt key was down when the event was fired. false otherwise. + /// + public bool AltKey { get; set; } + + /// + /// true if the meta key was down when the event was fired. false otherwise. + /// + public bool MetaKey { get; set; } } /// @@ -79,13 +308,72 @@ namespace Microsoft.AspNetCore.Blazor /// public class UIPointerEventArgs : UIMouseEventArgs { + /// + /// A unique identifier for the pointer causing the event. + /// + public string PointerId { get; set; } + + /// + /// The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. + /// + public float Width { get; set; } + + /// + /// The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. + /// + public float Height { get; set; } + + /// + /// The normalized pressure of the pointer input in the range of 0 to 1, + /// where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively. + /// + public float Pressure { get; set; } + + /// + /// The plane angle (in degrees, in the range of -90 to 90) between the Y-Z plane + /// and the plane containing both the transducer (e.g. pen stylus) axis and the Y axis. + /// + public float TiltX { get; set; } + + /// + /// The plane angle (in degrees, in the range of -90 to 90) between the X-Z plane + /// and the plane containing both the transducer (e.g. pen stylus) axis and the X axis. + /// + public float TiltY { get; set; } + + /// + /// Indicates the device type that caused the event. + /// Must be one of the strings mouse, pen or touch, or an empty string. + /// + public string PointerType { get; set; } + + /// + /// Indicates if the pointer represents the primary pointer of this pointer type. + /// + public bool IsPrimary { get; set; } } /// /// Supplies information about a progress event that is being raised. /// - public class UIProgressEventArgs : UIMouseEventArgs + public class UIProgressEventArgs : UIEventArgs { + /// + /// Whether or not the total size of the transfer is known. + /// + public bool LengthComputable { get; set; } + + /// + /// The number of bytes transferred since the beginning of the operation. + /// This doesn't include headers and other overhead, but only the content itself. + /// + public long Loaded { get; set; } + + /// + /// The total number of bytes of content that will be transferred during the operation. + /// If the total size is unknown, this value is zero. + /// + public long Total { get; set; } } /// @@ -93,12 +381,119 @@ namespace Microsoft.AspNetCore.Blazor /// public class UITouchEventArgs : UIEventArgs { + /// + /// A count of consecutive clicks that happened in a short amount of time, incremented by one. + /// + public float Detail { get; set; } + + /// + /// A list of for every point of contact currently touching the surface. + /// + public UITouchPoint[] Touches { get; set; } + + /// + /// A list of for every point of contact that is touching the surface and started on the element that is the target of the current event. + /// + public UITouchPoint[] TargetTouches { get; set; } + + /// + /// A list of Touches for every point of contact which contributed to the event. + /// For the touchstart event this must be a list of the touch points that just became active with the current event. + /// For the touchmove event this must be a list of the touch points that have moved since the last event. + /// For the touchend and touchcancel events this must be a list of the touch points that have just been removed from the surface. + /// + public UITouchPoint[] ChangedTouches { get; set; } + + /// + /// true if the control key was down when the event was fired. false otherwise. + /// + public bool CtrlKey { get; set; } + + /// + /// true if the shift key was down when the event was fired. false otherwise. + /// + public bool ShiftKey { get; set; } + + /// + /// true if the alt key was down when the event was fired. false otherwise. + /// + public bool AltKey { get; set; } + + /// + /// true if the meta key was down when the event was fired. false otherwise. + /// + public bool MetaKey { get; set; } + } + + /// + /// Represents a single contact point on a touch-sensitive device. + /// The contact point is commonly a finger or stylus and the device may be a touchscreen or trackpad. + /// + public class UITouchPoint + { + /// + /// A unique identifier for this Touch object. + /// A given touch point (say, by a finger) will have the same identifier for the duration of its movement around the surface. + /// This lets you ensure that you're tracking the same touch all the time. + /// + public long Identifier { get; set; } + + /// + /// The X coordinate of the touch point relative to the left edge of the screen. + /// + public long ScreenX { get; set; } + + /// + /// The Y coordinate of the touch point relative to the top edge of the screen. + /// + public long ScreenY { get; set; } + + /// + /// The X coordinate of the touch point relative to the left edge of the browser viewport, not including any scroll offset. + /// + public long ClientX { get; set; } + + /// + /// The Y coordinate of the touch point relative to the top edge of the browser viewport, not including any scroll offset. + /// + public long ClientY { get; set; } + + /// + /// The X coordinate of the touch point relative to the left edge of the document. + /// Unlike , this value includes the horizontal scroll offset, if any. + /// + public long PageX { get; set; } + + /// + /// The Y coordinate of the touch point relative to the top of the document. + /// Unlike , this value includes the vertical scroll offset, if any. + /// + public long PageY { get; set; } } /// /// Supplies information about a mouse wheel event that is being raised. /// - public class UIWheelEventArgs : UIEventArgs + public class UIWheelEventArgs : UIMouseEventArgs { + /// + /// The horizontal scroll amount. + /// + public double DeltaX { get; set; } + + /// + /// The vertical scroll amount. + /// + public double DeltaY { get; set; } + + /// + /// The scroll amount for the z-axis. + /// + public double DeltaZ { get; set; } + + /// + /// The unit of the delta values scroll amount. + /// + public long DeltaMode { get; set; } } } diff --git a/test/testapps/BasicTestApp/KeyPressEventComponent.cshtml b/test/testapps/BasicTestApp/KeyPressEventComponent.cshtml index 4f0f12119f..fe5a31a826 100644 --- a/test/testapps/BasicTestApp/KeyPressEventComponent.cshtml +++ b/test/testapps/BasicTestApp/KeyPressEventComponent.cshtml @@ -1,4 +1,4 @@ -@using System.Collections.Generic +@using System.Collections.Generic Type here:
    @@ -13,6 +13,7 @@ Type here: void OnKeyPressed(UIKeyboardEventArgs eventArgs) { + Console.WriteLine(JsonUtil.Serialize(eventArgs)); keysPressed.Add(eventArgs.Key); } } diff --git a/test/testapps/BasicTestApp/MouseEventComponent.cshtml b/test/testapps/BasicTestApp/MouseEventComponent.cshtml index c87e515b58..e99b7df432 100644 --- a/test/testapps/BasicTestApp/MouseEventComponent.cshtml +++ b/test/testapps/BasicTestApp/MouseEventComponent.cshtml @@ -1,4 +1,4 @@ -@using System.Collections.Generic +@using System.Collections.Generic

    Mouse position

    @@ -29,34 +29,44 @@ void OnMouseOver(UIMouseEventArgs e) { + DumpEvent(e); message += "onmouseover,"; StateHasChanged(); } void OnMouseOut(UIMouseEventArgs e) { + DumpEvent(e); message += "onmouseout,"; StateHasChanged(); } void OnMouseMove(UIMouseEventArgs e) { + DumpEvent(e); message += "onmousemove,"; StateHasChanged(); } void OnMouseDown(UIMouseEventArgs e) { + DumpEvent(e); message += "onmousedown,"; StateHasChanged(); } void OnMouseUp(UIMouseEventArgs e) { + DumpEvent(e); message += "onmouseup,"; StateHasChanged(); } + void DumpEvent(UIMouseEventArgs e) + { + Console.WriteLine(JsonUtil.Serialize(e)); + } + void Clear() { message = string.Empty; diff --git a/test/testapps/BasicTestApp/TouchEventComponent.cshtml b/test/testapps/BasicTestApp/TouchEventComponent.cshtml new file mode 100644 index 0000000000..46a0312d64 --- /dev/null +++ b/test/testapps/BasicTestApp/TouchEventComponent.cshtml @@ -0,0 +1,38 @@ +@using System.Collections.Generic + +
    +

    Touch position

    +

    + Output: @message +

    +

    + +

    +

    + +

    +
    + +@functions { + + string message; + + void OnTouch(UITouchEventArgs e) + { + message += e.Type; + Console.WriteLine(JsonUtil.Serialize(e)); + StateHasChanged(); + } + + void Clear() + { + message = string.Empty; + } +} \ No newline at end of file diff --git a/test/testapps/BasicTestApp/wwwroot/index.html b/test/testapps/BasicTestApp/wwwroot/index.html index a99aca087e..d4f052e4ea 100644 --- a/test/testapps/BasicTestApp/wwwroot/index.html +++ b/test/testapps/BasicTestApp/wwwroot/index.html @@ -1,4 +1,4 @@ - + @@ -18,6 +18,7 @@ +