private void TouchCancelHandler(TouchEvent <HTMLCanvasElement> evt) { evt.PreventDefault(); OngoingTouches.Clear(); LogMessage("touchcancel."); }
public void OnTouchEnd(ElementEvent e) { TouchEvent ev = (TouchEvent)e; ev.PreventDefault(); mouseDown = false; }
public void OnTouchStart(ElementEvent e) { TouchEvent ev = (TouchEvent)e; ev.PreventDefault(); mouseDown = true; lastX = ev.TargetTouches[0].PageX; lastY = ev.TargetTouches[0].PageY; }
static void OnTouchEnd(TouchEvent <HTMLCanvasElement> e) { e.PreventDefault(); foreach (var t in e.ChangedTouches) { _history.Remove(t.Identifier); } Redraw(); }
public void OnTouchStart(ElementEvent e) { TouchEvent ev = (TouchEvent)e; ev.PreventDefault(); mouseDown = true; lastX = ev.TargetTouches[0].PageX; lastY = ev.TargetTouches[0].PageY; indexTouchDown = GetItemIndexFromCursor(Vector2d.Create(ev.TargetTouches[0].PageX, ev.TargetTouches[0].PageY)); }
static void SetTouchDown(TouchEvent <HTMLCanvasElement> e) { if (e.Touches[0].ClientX < screen.ClientWidth / 2) { chip8.KeyDown(keyMapping[KeyCode.LeftCursor]); } else { chip8.KeyDown(keyMapping[KeyCode.RightCursor]); } e.PreventDefault(); }
public void OnTouchMove(ElementEvent e) { TouchEvent ev = (TouchEvent)e; ev.PreventDefault(); if (mouseDown) { double curX = ev.TargetTouches[0].PageX - lastX; double curY = ev.TargetTouches[0].PageY - lastY; if (mouseDown) { dragging = true; } if (!dragging) { int newHover = GetItemIndexFromCursor(Vector2d.Create(ev.TargetTouches[0].PageX, ev.TargetTouches[0].PageY)); if (hoverItem != newHover) { hoverItem = newHover; //if (ItemHover != null) //{ // if (hoverItem > -1) // { // ItemHover.Invoke(this, items[hoverItem]); // } // else // { // ItemHover.Invoke(this, null); // } //} } } else { int tiles = (int)Math.Round(((ev.TargetTouches[0].PageX - lastX) + startOffset) / HorzSpacing); int offset = (int)Math.Round(((ev.TargetTouches[0].PageX - lastX) + startOffset) - (tiles * HorzSpacing)); startOffset = offset; startIndex -= tiles; if (startIndex < 0) { startOffset -= (HorzSpacing * startIndex); startIndex = 0; } lastX = ev.TargetTouches[0].PageX; lastY = ev.TargetTouches[0].PageY; } Refresh(); } }
static void OnTouchMove(TouchEvent <HTMLCanvasElement> e) { e.PreventDefault(); foreach (var t in e.ChangedTouches) { var th = _history.Find(t.Identifier); if (th != null) { th.AddEvent(t); } } Redraw(); }
static void OnTouchStart(TouchEvent <HTMLCanvasElement> e) { e.PreventDefault(); foreach (var t in e.ChangedTouches) { var th = new TouchHistory() { Id = t.Identifier }; th.AddEvent(t); _history.Add(th); } Redraw(); }
/// <summary> /// Handles touch events. /// </summary> /// <param name="e">The browser event.</param> private void handleTouchEvent_(TouchEvent e) { var be = new goog.events.BrowserEvent(e); e.PreventDefault(); var node = this.getNodeFromEvent_(be); if (node != null && e.Type == goog.events.EventType.TOUCHSTART) { // Fire asynchronously since onMouseDown takes long enough that the browser // would fire the default mouse event before this method returns. Window.SetTimeout(() => { node.onMouseDown(be); // Same behaviour for click and touch. }, 1); } }
public void OnTouchMove(ElementEvent e) { TouchEvent ev = (TouchEvent)e; ev.PreventDefault(); if (mouseDown) { double curX = ev.TargetTouches[0].PageX - lastX; double curY = ev.TargetTouches[0].PageY - lastY; Move(curX, curY); lastX = ev.TargetTouches[0].PageX; lastY = ev.TargetTouches[0].PageY; } }
public void OnTouchEnd(ElementEvent e) { TouchEvent ev = (TouchEvent)e; ev.PreventDefault(); if (dragging) { dragging = false; ignoreClick = true; } else if (indexTouchDown > -1 && mouseDown) { HandleClick(indexTouchDown); } startOffset = 0; mouseDown = false; Refresh(); }
private void TouchMoveHandler(TouchEvent <HTMLCanvasElement> evt) { evt.PreventDefault(); var ctx = this.Context2D; var touches = evt.ChangedTouches; for (var i = 0; i < touches.Length; i++) { var t = touches[i]; var idx = this.OngoingTouchIndexById(t.Identifier); if (idx >= 0) { this.LogMessage("continuing touch " + idx); var color = this.ColorForTouch(t, t.Identifier + " move idx " + idx + " "); ctx.BeginPath(); var ogt = OngoingTouches[idx]; this.LogMessage("ctx.moveTo(" + ogt.PageX + ", " + ogt.PageY + ");"); ctx.MoveTo(ogt.PageX, ogt.PageY); this.LogMessage("ctx.lineTo(" + t.PageX + ", " + t.PageY + ");"); ctx.LineTo(t.PageX, t.PageY); ctx.LineWidth = 4; ctx.StrokeStyle = color; ctx.Stroke(); OngoingTouches[idx] = CopyTouch(t); // swap in the new touch record this.LogMessage("continued ."); } else { this.LogMessage("can't figure out which touch to continue"); } } }
public static void TouchStart(TouchEvent evt) { // With JQuery: $(document).bind("touchstart", function(e) {...} evt.PreventDefault(); JsString target_id = evt.target.id; if (isMoving == false && movingItems[target_id] == 1) { isMoving = true; //var orig = e.originalEvent; TouchEvent orig = evt; int x = orig.touches[0].pageX - imgOffset; int y = orig.touches[0].pageY - imgOffset; //Set the item to moving, and update the position and zIndex movingItems[target_id] = 2; HtmlElement.GetById(target_id).style.top = y + "px"; HtmlElement.GetById(target_id).style.left = x + "px"; // With JQuery: $("#dragItem").css({top: y, left: x}); HtmlElement.GetById(target_id).style.zIndex = "2000"; } }
public static void TouchMove(TouchEvent evt) { // With JQuery: $(document).bind("touchmove", function(e) {...} evt.PreventDefault(); JsString target_id = evt.target.id; //Check that the target element is registered and flagged as moving if (movingItems[target_id].As <bool>() && movingItems[target_id] == 2) { //var orig = e.originalEvent; TouchEvent orig = evt; if (orig.touches.length > 1) { return; } int x = orig.touches[0].pageX - imgOffset; int y = orig.touches[0].pageY - imgOffset; HtmlElement.GetById(target_id).style.top = y + "px"; HtmlElement.GetById(target_id).style.left = x + "px"; // With JQuery: $("#dragItem").css({top: y, left: x}); } }
private void TouchEndHandler(TouchEvent <HTMLCanvasElement> evt) { evt.PreventDefault(); this.LogMessage("touchend"); var ctx = this.Context2D; var touches = evt.ChangedTouches; for (var i = 0; i < touches.Length; i++) { var t = touches[i]; var idx = OngoingTouchIndexById(t.Identifier); if (idx >= 0) { var color = this.ColorForTouch(t, t.Identifier + " end idx " + idx + " "); ctx.LineWidth = 4; ctx.FillStyle = color; ctx.BeginPath(); var ogt = OngoingTouches[idx]; ctx.MoveTo(ogt.PageX, ogt.PageY); ctx.LineTo(t.PageX, t.PageY); ctx.FillRect(t.PageX - 4, t.PageY - 4, 8, 8); // and a square at the end OngoingTouches.RemoveAt(idx); // remove it; we're done } else { this.LogMessage("can't figure out which touch to end"); } } }
static void OnTouchLeave(TouchEvent <HTMLCanvasElement> e) { e.PreventDefault(); }
public static void TouchStart(TouchEvent evt) { // With JQuery: $(document).bind("touchstart", function(e) {...} evt.PreventDefault(); JsString target_id = evt.target.id; if (isMoving == false && movingItems[target_id] == 1) { isMoving = true; //var orig = e.originalEvent; TouchEvent orig = evt; int x = orig.touches[0].pageX - imgOffset; int y = orig.touches[0].pageY - imgOffset; //Set the item to moving, and update the position and zIndex movingItems[target_id] = 2; HtmlElement.GetById(target_id).style.top = y + "px"; HtmlElement.GetById(target_id).style.left = x + "px"; // With JQuery: $("#dragItem").css({top: y, left: x}); HtmlElement.GetById(target_id).style.zIndex = "2000"; } }
static void SetTouchUp(TouchEvent <HTMLCanvasElement> e) { chip8.KeyUp(keyMapping[KeyCode.LeftCursor]); chip8.KeyUp(keyMapping[KeyCode.RightCursor]); e.PreventDefault(); }
public static void TouchMove(TouchEvent evt) { // With JQuery: $(document).bind("touchmove", function(e) {...} evt.PreventDefault(); JsString target_id = evt.target.id; //Check that the target element is registered and flagged as moving if (movingItems[target_id].As<bool>() && movingItems[target_id] == 2) { //var orig = e.originalEvent; TouchEvent orig = evt; if (orig.touches.length > 1) return; int x = orig.touches[0].pageX - imgOffset; int y = orig.touches[0].pageY - imgOffset; HtmlElement.GetById(target_id).style.top = y + "px"; HtmlElement.GetById(target_id).style.left = x + "px"; // With JQuery: $("#dragItem").css({top: y, left: x}); } }