public void OnDragStart(dfControl control, dfDragEventArgs args) { if (args.Used) { isMouseDown = false; } }
public void OnDragStart(dfControl control, dfDragEventArgs dragEvent) { isDragging = true; dragEvent.Data = control.Color; dragEvent.State = dfDragDropState.Dragging; dragEvent.Use(); }
public void OnDragStart( dfControl control, dfDragEventArgs dragEvent ) { isDragging = true; dragEvent.Data = control.Color; dragEvent.State = dfDragDropState.Dragging; dragEvent.Use(); }
internal override void OnDragStart(dfDragEventArgs args) { base.OnDragStart(args); if (args.Used) { isMouseDown = false; } }
public void OnDragDrop( dfControl control, dfDragEventArgs dragEvent ) { var data = ( dragEvent.Data == null ) ? "(null)" : dragEvent.Data.ToString(); display( "DragDrop: " + data ); dragEvent.State = dfDragDropState.Dropped; dragEvent.Use(); }
public void OnDragStart(dfControl source, dfDragEventArgs args) { if (spec == null) return; args.Data = this; args.State = dfDragDropState.Dragging; args.Use(); DragCursor.Show(this, args.Position); }
public void OnDragDrop( dfControl control, dfDragEventArgs dragEvent ) { if( dragEvent.Data is Color32 ) { control.Color = (Color32)dragEvent.Data; dragEvent.State = dfDragDropState.Dropped; dragEvent.Use(); } }
public void OnDragDrop(dfControl control, dfDragEventArgs dragEvent) { if (dragEvent.Data is Color32) { control.Color = (Color32)dragEvent.Data; dragEvent.State = dfDragDropState.Dropped; dragEvent.Use(); } }
public void OnDragStart( dfControl control, dfDragEventArgs dragEvent ) { _label.Text = "Dragging..."; dragEvent.Data = this.name; dragEvent.State = dfDragDropState.Dragging; dragEvent.Use(); isDragging = true; }
private bool allowDrop( dfDragEventArgs args ) { if( isSpellActive ) return false; // Only allow drop if the source is another SpellSlot and // this SpellSlot is assignable var slot = args.Data as SpellSlot; return slot != null && this.IsActionSlot; }
void button_DragStart(dfControl control, dfDragEventArgs dragEvent) { BrainButton bb = control as BrainButton; draggedBrain = bb.Brain; dragEvent.State = dfDragDropState.Dragging; dragEvent.Data = this; Cursor.SetCursor(mouseCursor, Vector2.zero, CursorMode.Auto); print("Drag start"); }
public void OnDragStart(dfControl source, dfDragEventArgs args) { if (this.Count > 0) { args.Data = this; args.State = dfDragDropState.Dragging; args.Use(); DnDExample_DragCursor.Show(this, args.Position); } }
void slot1_DragEnter(dfControl control, dfDragEventArgs dragEvent) { dfPanel panel = control as dfPanel; print("Drag enter"); if (draggedBrain != null) { panel.BackgroundColor = new Color32(255, 255, 255, 255); activeSlot = panel; } }
public void OnDragStart( dfControl source, dfDragEventArgs args ) { if( this.Count > 0 ) { args.Data = this; args.State = dfDragDropState.Dragging; args.Use(); DnDExample_DragCursor.Show( this, args.Position ); } }
public void OnDragEnd( dfControl control, dfDragEventArgs dragEvent ) { if( dragEvent.State == dfDragDropState.Dropped ) { _label.Text = "Dropped on " + dragEvent.Target.name; } else { _label.Text = "Drag Ended: " + dragEvent.State; } isDragging = false; }
public void OnDragEnd(dfControl source, dfDragEventArgs args) { DnDExample_DragCursor.Hide(); if (args.State == dfDragDropState.Dropped) { this.Count = 0; this.ItemName = ""; this.Icon = ""; Refresh(); } }
private bool allowDrop(dfDragEventArgs args) { if (isSpellActive) { return(false); } // Only allow drop if the source is another SpellSlot and // this SpellSlot is assignable var slot = args.Data as SpellSlot; return(slot != null && this.IsActionSlot); }
public void OnDragDrop(dfControl source, dfDragEventArgs args) { if (this.Count == 0 && args.Data is DndExample_InventoryItem) { var item = (DndExample_InventoryItem)args.Data; this.ItemName = item.ItemName; this.Icon = item.Icon; this.Count = item.Count; args.State = dfDragDropState.Dropped; args.Use(); } Refresh(); }
public void OnDragEnd( dfControl source, dfDragEventArgs args ) { DnDExample_DragCursor.Hide(); if( args.State == dfDragDropState.Dropped ) { this.Count = 0; this.ItemName = ""; this.Icon = ""; Refresh(); } }
void OnDragEnd(dfControl source, dfDragEventArgs args) { ActionbarsDragCursor.Hide(); if (!this.isActionSlot) { return; } if (args.State == dfDragDropState.CancelledNoTarget) { Spell = ""; } refresh(); }
public void OnDragDrop(dfControl source, dfDragEventArgs args) { if (isEquipSlot && args.Data is DraggableSpecialization) { var item = (DraggableSpecialization)args.Data; spec = item.spec; this.name = item.spec.name; this.Icon = item.spec.icon; args.State = dfDragDropState.Dropped; args.Use(); espec.setEquiped(spec); } }
public void OnDragDrop( dfControl source, dfDragEventArgs args ) { if( this.Count == 0 && args.Data is DndExample_InventoryItem ) { var item = (DndExample_InventoryItem)args.Data; this.ItemName = item.ItemName; this.Icon = item.Icon; this.Count = item.Count; args.State = dfDragDropState.Dropped; args.Use(); } Refresh(); }
void OnDragStart(dfControl source, dfDragEventArgs args) { if (allowDrag(args)) { if (string.IsNullOrEmpty(Spell)) { // Indicates that the drag-and-drop operation cannot be performed args.State = dfDragDropState.Denied; } else { // Get the offset that will be used for the drag cursor var sprite = GetComponent <dfControl>().Find("Icon") as dfSprite; var ray = sprite.GetCamera().ScreenPointToRay(Input.mousePosition); var dragCursorOffset = Vector2.zero; if (!sprite.GetHitPosition(ray, out dragCursorOffset)) { return; } // Set the variables that will be used to render the drag cursor. // The UI library provides all of the drag and drop events necessary // but does not provide a default drag visualization and requires // that the application provide the visualization. We'll do that by // supplying a Texture2D that will be placed at the mouse location // in the OnGUI() method. ActionbarsDragCursor.Show(sprite, Input.mousePosition, dragCursorOffset); if (IsActionSlot) { // Visually indicate that they are *moving* the spell rather than // just dragging it into a slot sprite.SpriteName = ""; } // Indicate that the drag and drop operation can continue and set // the user-defined data that will be sent to potential drop targets args.State = dfDragDropState.Dragging; args.Data = this; } // Do not let the OnDragStart event "bubble up" to higher-level controls args.Use(); } }
void slot1_DragDrop(dfControl control, dfDragEventArgs dragEvent) { dfPanel panel = control as dfPanel; BrainPanelState brainPanel = panel.GetComponent <BrainPanelState>(); if (draggedBrain != null) { if (draggedBrain.ChampionGene == null) { // _dialog.ShowDialog("This brain has not been trained yet and cannot be used in battle mode."); brainPanel.Refresh(); return; } brainPanel.AddBrain(draggedBrain); } }
void slot1_DragLeave(dfControl control, dfDragEventArgs dragEvent) { dfPanel panel = control as dfPanel; panel.GetComponent <BrainPanelState>().Refresh(); //switch (control.gameObject.name) //{ // case "Slot 1": // panel.BackgroundColor = slot1Color; // break; // case "Slot 2": // panel.BackgroundColor = slot2Color; // break; // case "Slot 3": // panel.BackgroundColor = slot3Color; // break; // case "Slot 4": // panel.BackgroundColor = slot4Color; // break; //} }
void OnDragDrop(dfControl source, dfDragEventArgs args) { if (allowDrop(args)) { args.State = dfDragDropState.Dropped; var otherSlot = args.Data as SpellSlot; var temp = this.spellName; this.Spell = otherSlot.Spell; if (otherSlot.IsActionSlot) { otherSlot.Spell = temp; } } else { args.State = dfDragDropState.Denied; } args.Use(); }
private bool allowDrag( dfDragEventArgs args ) { // Do not allow the user to drag and drop empty SpellSlot instances return !isSpellActive && !string.IsNullOrEmpty( spellName ); }
public void OnDragEnd( dfControl source, dfDragEventArgs args ) { isDragging = false; }
public void OnDragStart( dfControl control, dfDragEventArgs args ) { if( args.Used ) { isMouseDown = false; } }
private void DragEventProxy(dfControl control, dfDragEventArgs dragEvent) { this.callProxyEventHandler(); }
private void DragEventProxy( dfControl control, dfDragEventArgs dragEvent ) { callProxyEventHandler(); }
internal override void OnDragEnd(dfDragEventArgs args) { base.OnDragEnd(args); isMouseDown = false; }
public void ProcessInput(IInputAdapter adapter, Ray ray, dfControl control, bool retainFocusSetting) { Vector2 mousePosition = adapter.GetMousePosition(); this.buttonsDown = dfMouseButtons.None; this.buttonsReleased = dfMouseButtons.None; this.buttonsPressed = dfMouseButtons.None; dfInputManager.MouseInputManager.getMouseButtonInfo(adapter, ref this.buttonsDown, ref this.buttonsReleased, ref this.buttonsPressed); float axis = adapter.GetAxis("Mouse ScrollWheel"); if (!Mathf.Approximately(axis, 0f)) { axis = Mathf.Sign(axis) * Mathf.Max(1f, Mathf.Abs(axis)); } this.mouseMoveDelta = mousePosition - this.lastPosition; this.lastPosition = mousePosition; if (this.dragState == dfDragDropState.Dragging) { if (this.buttonsReleased == dfMouseButtons.None) { if (control == this.activeControl) { return; } if (control == this.lastDragControl) { if (control != null && Vector2.Distance(mousePosition, this.lastPosition) > 1f) { dfDragEventArgs dfDragEventArg = new dfDragEventArgs(control, this.dragState, this.dragData, ray, mousePosition); control.OnDragOver(dfDragEventArg); } return; } if (this.lastDragControl != null) { dfDragEventArgs dfDragEventArg1 = new dfDragEventArgs(this.lastDragControl, this.dragState, this.dragData, ray, mousePosition); this.lastDragControl.OnDragLeave(dfDragEventArg1); } if (control != null) { dfDragEventArgs dfDragEventArg2 = new dfDragEventArgs(control, this.dragState, this.dragData, ray, mousePosition); control.OnDragEnter(dfDragEventArg2); } this.lastDragControl = control; return; } if (!(control != null) || !(control != this.activeControl)) { dfDragDropState _dfDragDropState = (control != null ? dfDragDropState.Cancelled : dfDragDropState.CancelledNoTarget); dfDragEventArgs dfDragEventArg3 = new dfDragEventArgs(this.activeControl, _dfDragDropState, this.dragData, ray, mousePosition); this.activeControl.OnDragEnd(dfDragEventArg3); } else { dfDragEventArgs dfDragEventArg4 = new dfDragEventArgs(control, dfDragDropState.Dragging, this.dragData, ray, mousePosition); control.OnDragDrop(dfDragEventArg4); if (!dfDragEventArg4.Used || dfDragEventArg4.State == dfDragDropState.Dragging) { dfDragEventArg4.State = dfDragDropState.Cancelled; } dfDragEventArg4 = new dfDragEventArgs(this.activeControl, dfDragEventArg4.State, dfDragEventArg4.Data, ray, mousePosition) { Target = control }; this.activeControl.OnDragEnd(dfDragEventArg4); } this.dragState = dfDragDropState.None; this.lastDragControl = null; this.activeControl = null; this.lastClickTime = 0f; this.lastHoverTime = 0f; this.lastPosition = mousePosition; return; } if (this.buttonsReleased != dfMouseButtons.None) { this.lastHoverTime = Time.realtimeSinceStartup + 0.25f; if (this.activeControl == null) { this.setActive(control, mousePosition, ray); return; } if (this.activeControl == control && this.buttonsDown == dfMouseButtons.None) { if (Time.realtimeSinceStartup - this.lastClickTime >= 0.25f) { this.lastClickTime = Time.realtimeSinceStartup; this.activeControl.OnClick(new dfMouseEventArgs(this.activeControl, this.buttonsReleased, 1, ray, mousePosition, axis)); } else { this.lastClickTime = 0f; this.activeControl.OnDoubleClick(new dfMouseEventArgs(this.activeControl, this.buttonsReleased, 1, ray, mousePosition, axis)); } } this.activeControl.OnMouseUp(new dfMouseEventArgs(this.activeControl, this.buttonsReleased, 0, ray, mousePosition, axis)); if (this.buttonsDown == dfMouseButtons.None && this.activeControl != control) { this.setActive(null, mousePosition, ray); } return; } if (this.buttonsPressed != dfMouseButtons.None) { this.lastHoverTime = Time.realtimeSinceStartup + 0.25f; if (this.activeControl == null) { this.setActive(control, mousePosition, ray); if (control != null) { control.OnMouseDown(new dfMouseEventArgs(control, this.buttonsPressed, 0, ray, mousePosition, axis)); } else if (!retainFocusSetting) { dfControl activeControl = dfGUIManager.ActiveControl; if (activeControl != null) { activeControl.Unfocus(); } } } else { this.activeControl.OnMouseDown(new dfMouseEventArgs(this.activeControl, this.buttonsPressed, 0, ray, mousePosition, axis)); } return; } if (this.activeControl != null && this.activeControl == control && this.mouseMoveDelta.magnitude == 0f && Time.realtimeSinceStartup - this.lastHoverTime > 0.1f) { this.activeControl.OnMouseHover(new dfMouseEventArgs(this.activeControl, this.buttonsDown, 0, ray, mousePosition, axis)); this.lastHoverTime = Time.realtimeSinceStartup; } if (this.buttonsDown == dfMouseButtons.None) { if (axis != 0f && control != null) { this.setActive(control, mousePosition, ray); control.OnMouseWheel(new dfMouseEventArgs(control, this.buttonsDown, 0, ray, mousePosition, axis)); return; } this.setActive(control, mousePosition, ray); } else if (this.activeControl != null) { if (control != null) { control.RenderOrder <= this.activeControl.RenderOrder; } if (this.mouseMoveDelta.magnitude >= 2f && (this.buttonsDown & (dfMouseButtons.Left | dfMouseButtons.Right)) != dfMouseButtons.None && this.dragState != dfDragDropState.Denied) { dfDragEventArgs dfDragEventArg5 = new dfDragEventArgs(this.activeControl) { Position = mousePosition }; this.activeControl.OnDragStart(dfDragEventArg5); if (dfDragEventArg5.State == dfDragDropState.Dragging) { this.dragState = dfDragDropState.Dragging; this.dragData = dfDragEventArg5.Data; return; } this.dragState = dfDragDropState.Denied; } } if (this.activeControl != null && this.mouseMoveDelta.magnitude >= 1f) { dfMouseEventArgs dfMouseEventArg = new dfMouseEventArgs(this.activeControl, this.buttonsDown, 0, ray, mousePosition, axis) { MoveDelta = this.mouseMoveDelta }; this.activeControl.OnMouseMove(dfMouseEventArg); } }
internal override void OnDragStart( dfDragEventArgs args ) { base.OnDragStart( args ); if( args.Used ) { isMouseDown = false; } }
private bool allowDrag(dfDragEventArgs args) { // Do not allow the user to drag and drop empty SpellSlot instances return(!isSpellActive && !string.IsNullOrEmpty(spellName)); }
public void DragEventProxy(dfControl control, dfDragEventArgs dragEvent) { callProxyEventHandler(control, dragEvent); }
void OnDragStart( dfControl source, dfDragEventArgs args ) { if( allowDrag( args ) ) { if( string.IsNullOrEmpty( Spell ) ) { // Indicates that the drag-and-drop operation cannot be performed args.State = dfDragDropState.Denied; } else { // Get the offset that will be used for the drag cursor var sprite = GetComponent<dfControl>().Find( "Icon" ) as dfSprite; var ray = sprite.GetCamera().ScreenPointToRay( Input.mousePosition ); var dragCursorOffset = Vector2.zero; if( !sprite.GetHitPosition( ray, out dragCursorOffset ) ) return; // Set the variables that will be used to render the drag cursor. // The UI library provides all of the drag and drop events necessary // but does not provide a default drag visualization and requires // that the application provide the visualization. We'll do that by // supplying a Texture2D that will be placed at the mouse location // in the OnGUI() method. ActionbarsDragCursor.Show( sprite, Input.mousePosition, dragCursorOffset ); if( IsActionSlot ) { // Visually indicate that they are *moving* the spell rather than // just dragging it into a slot sprite.SpriteName = ""; } // Indicate that the drag and drop operation can continue and set // the user-defined data that will be sent to potential drop targets args.State = dfDragDropState.Dragging; args.Data = this; } // Do not let the OnDragStart event "bubble up" to higher-level controls args.Use(); } }
void OnDragEnd( dfControl source, dfDragEventArgs args ) { ActionbarsDragCursor.Hide(); if( !this.isActionSlot ) return; if( args.State == dfDragDropState.CancelledNoTarget ) { Spell = ""; } refresh(); }
public void OnDragEnd(dfControl source, dfDragEventArgs args) { DragCursor.Hide(); }
public void ProcessInput( dfInputManager manager, IInputAdapter adapter, Ray ray, dfControl control, bool retainFocusSetting ) { var position = adapter.GetMousePosition(); buttonsDown = dfMouseButtons.None; buttonsReleased = dfMouseButtons.None; buttonsPressed = dfMouseButtons.None; getMouseButtonInfo( adapter, ref buttonsDown, ref buttonsReleased, ref buttonsPressed ); float scroll = adapter.GetAxis( scrollAxisName ); if( !Mathf.Approximately( scroll, 0f ) ) { // By default the mouse wheel is reported in increments of 0.1f, // which is just a useless number for UI, but this can be changed // by the user in the Unity Input Manager. We'll assume that if the // number reported is less than 1 then it is probably safe to // assume that we can massage it for UI purposes. scroll = Mathf.Sign( scroll ) * Mathf.Max( 1, Mathf.Abs( scroll ) ); } mouseMoveDelta = position - lastPosition; lastPosition = position; #region Drag and drop if( dragState == dfDragDropState.Dragging ) { if( buttonsReleased == dfMouseButtons.None ) { // Do nothing if the drag operation is over the source control // and no buttons have been released. if( control == activeControl ) return; if( control != lastDragControl ) { if( lastDragControl != null ) { var dragArgs = new dfDragEventArgs( lastDragControl, dragState, dragData, ray, position ); lastDragControl.OnDragLeave( dragArgs ); } if( control != null ) { var dragArgs = new dfDragEventArgs( control, dragState, dragData, ray, position ); control.OnDragEnter( dragArgs ); } lastDragControl = control; return; } if( control != null ) { if( mouseMoveDelta.magnitude > 1.0f ) { var dragArgs = new dfDragEventArgs( control, dragState, dragData, ray, position ); control.OnDragOver( dragArgs ); } } return; } if( control != null && control != activeControl ) { var dragArgs = new dfDragEventArgs( control, dfDragDropState.Dragging, dragData, ray, position ); control.OnDragDrop( dragArgs ); // If there was no event consumer, or if the event consumer did not // change the state from Dragging (which is not a valid state for // a drop event) then just cancel the operation if( !dragArgs.Used || dragArgs.State == dfDragDropState.Dragging ) dragArgs.State = dfDragDropState.Cancelled; dragArgs = new dfDragEventArgs( activeControl, dragArgs.State, dragArgs.Data, ray, position ); dragArgs.Target = control; activeControl.OnDragEnd( dragArgs ); } else { var cancelState = ( control == null ) ? dfDragDropState.CancelledNoTarget : dfDragDropState.Cancelled; var dragArgs = new dfDragEventArgs( activeControl, cancelState, dragData, ray, position ); activeControl.OnDragEnd( dragArgs ); } dragState = dfDragDropState.None; lastDragControl = null; activeControl = null; lastClickTime = 0f; lastHoverTime = 0f; lastPosition = position; return; } #endregion #region Mouse button pressed if( buttonsPressed != dfMouseButtons.None ) { lastHoverTime = Time.realtimeSinceStartup + manager.hoverStartDelay; if( activeControl != null ) { // If a control has capture, forward all events to it if( activeControl.transform.IsChildOf( manager.transform ) ) { activeControl.OnMouseDown( new dfMouseEventArgs( activeControl, buttonsPressed, 0, ray, position, scroll ) ); } } else if( control == null || control.transform.IsChildOf( manager.transform ) ) { setActive( manager, control, position, ray ); if( control != null ) { dfGUIManager.SetFocus( control ); control.OnMouseDown( new dfMouseEventArgs( control, buttonsPressed, 0, ray, position, scroll ) ); } else if( !retainFocusSetting ) { var focusControl = dfGUIManager.ActiveControl; if( focusControl != null && focusControl.transform.IsChildOf( manager.transform ) ) { focusControl.Unfocus(); } } } if( buttonsReleased == dfMouseButtons.None ) return; } #endregion #region Mouse button released if( buttonsReleased != dfMouseButtons.None ) { lastHoverTime = Time.realtimeSinceStartup + manager.hoverStartDelay; // Mouse up without a control having capture is ignored if( activeControl == null ) { setActive( manager, control, position, ray ); return; } // If the mouse button is released over the same control it was pressed on, // the Click event gets generated (in addition to MouseUp) if( activeControl == control && buttonsDown == dfMouseButtons.None ) { var p2u = activeControl.PixelsToUnits(); var startPosition = activeControlPosition / p2u; var currentPosition = activeControl.transform.position / p2u; // Don't fire click events if the control has been moved since the mouse was down if( Vector3.Distance( startPosition, currentPosition ) <= 1 ) { if( Time.realtimeSinceStartup - lastClickTime < DOUBLECLICK_TIME ) { lastClickTime = 0f; activeControl.OnDoubleClick( new dfMouseEventArgs( activeControl, buttonsReleased, 1, ray, position, scroll ) ); } else { lastClickTime = Time.realtimeSinceStartup; activeControl.OnClick( new dfMouseEventArgs( activeControl, buttonsReleased, 1, ray, position, scroll ) ); } } } // Let the last control know that the button was released whether it was // released over the control or not activeControl.OnMouseUp( new dfMouseEventArgs( activeControl, buttonsReleased, 0, ray, position, scroll ) ); // If all buttons are up, then we need to reset the mouse state if( buttonsDown == dfMouseButtons.None && activeControl != control ) { setActive( manager, null, position, ray ); } return; } #endregion #region Doesn't matter if buttons are down or not if( activeControl != null && activeControl == control ) { if( mouseMoveDelta.magnitude == 0 && Time.realtimeSinceStartup - lastHoverTime > manager.hoverNotifactionFrequency ) { activeControl.OnMouseHover( new dfMouseEventArgs( activeControl, buttonsDown, 0, ray, position, scroll ) ); lastHoverTime = Time.realtimeSinceStartup; } } #endregion #region No buttons down if( buttonsDown == dfMouseButtons.None ) { if( scroll != 0 && control != null ) { setActive( manager, control, position, ray ); control.OnMouseWheel( new dfMouseEventArgs( control, buttonsDown, 0, ray, position, scroll ) ); return; } setActive( manager, control, position, ray ); } #endregion #region Some buttons down else if( buttonsDown != dfMouseButtons.None ) // Some buttons are down { if( activeControl != null ) { // Special case: Another control with a higher RenderOrder is now under the mouse. // This can happen when a control moves, such as when you click on a slider and the // thumb position is updated to be under the mouse (when it wasn't previously) if( control != null && control.RenderOrder > activeControl.RenderOrder ) { // TODO: What to do about this when a control has capture? } // If the mouse was moved notify the control, otherwise nothing to do // NOTE: This is similar to "mouse capture" on Windows Forms if( mouseMoveDelta.magnitude >= DRAG_START_DELTA ) { if( ( buttonsDown & ( dfMouseButtons.Left | dfMouseButtons.Right ) ) != 0 && dragState != dfDragDropState.Denied ) { var dragArgs = new dfDragEventArgs( activeControl ) { Position = position }; activeControl.OnDragStart( dragArgs ); if( dragArgs.State == dfDragDropState.Dragging ) { dragState = dfDragDropState.Dragging; dragData = dragArgs.Data; return; } else { dragState = dfDragDropState.Denied; } } } } } #endregion if( activeControl != null && mouseMoveDelta.magnitude >= 1 ) { var moveArgs = new dfMouseEventArgs( activeControl, buttonsDown, 0, ray, position, scroll ) { MoveDelta = mouseMoveDelta }; activeControl.OnMouseMove( moveArgs ); } }
internal override void OnDragEnd( dfDragEventArgs args ) { base.OnDragEnd( args ); isMouseDown = false; }
public bool Process(dfInputManager.TouchInputManager.TouchRaycast info) { if (this.IsDragging) { if (!this.capture.Contains(info.FingerID)) { return(false); } if (info.Phase == TouchPhase.Stationary) { return(true); } if (info.Phase == TouchPhase.Canceled) { this.control.OnDragEnd(new dfDragEventArgs(this.control, dfDragDropState.Cancelled, this.dragData, info.ray, info.position)); this.dragState = dfDragDropState.None; this.touches.Clear(); this.capture.Clear(); return(true); } if (info.Phase != TouchPhase.Ended) { return(true); } if (info.control == null || info.control == this.control) { this.control.OnDragEnd(new dfDragEventArgs(this.control, dfDragDropState.CancelledNoTarget, this.dragData, info.ray, info.position)); this.dragState = dfDragDropState.None; this.touches.Clear(); this.capture.Clear(); return(true); } dfDragEventArgs dfDragEventArg = new dfDragEventArgs(info.control, dfDragDropState.Dragging, this.dragData, info.ray, info.position); info.control.OnDragDrop(dfDragEventArg); if (!dfDragEventArg.Used || dfDragEventArg.State != dfDragDropState.Dropped) { dfDragEventArg.State = dfDragDropState.Cancelled; } dfDragEventArgs dfDragEventArg1 = new dfDragEventArgs(this.control, dfDragEventArg.State, this.dragData, info.ray, info.position) { Target = info.control }; this.control.OnDragEnd(dfDragEventArg1); this.dragState = dfDragDropState.None; this.touches.Clear(); this.capture.Clear(); return(true); } if (!this.touches.ContainsKey(info.FingerID)) { if (info.control != this.control) { return(false); } this.touches[info.FingerID] = info; if (this.touches.Count == 1) { this.control.OnMouseEnter(info); if (info.Phase == TouchPhase.Began) { this.capture.Add(info.FingerID); this.control.OnMouseDown(info); } return(true); } if (info.Phase == TouchPhase.Began) { this.control.OnMouseUp(info); this.control.OnMouseLeave(info); List <Touch> activeTouches = this.getActiveTouches(); dfTouchEventArgs dfTouchEventArg = new dfTouchEventArgs(this.control, activeTouches, info.ray); this.control.OnMultiTouch(dfTouchEventArg); } return(true); } if (info.Phase == TouchPhase.Canceled || info.Phase == TouchPhase.Ended) { dfInputManager.TouchInputManager.TouchRaycast item = this.touches[info.FingerID]; this.touches.Remove(info.FingerID); if (this.touches.Count == 0) { if (this.capture.Contains(info.FingerID)) { if (this.canFireClickEvent(info, item) && info.control == this.control) { if (info.touch.tapCount <= 1) { this.control.OnClick(info); } else { this.control.OnDoubleClick(info); } } this.control.OnMouseUp(info); } this.control.OnMouseLeave(info); this.capture.Remove(info.FingerID); return(true); } this.capture.Remove(info.FingerID); if (this.touches.Count == 1) { dfTouchEventArgs dfTouchEventArg1 = this.touches.Values.First <dfInputManager.TouchInputManager.TouchRaycast>(); this.control.OnMouseEnter(dfTouchEventArg1); this.control.OnMouseDown(dfTouchEventArg1); return(true); } } if (this.touches.Count > 1) { List <Touch> touches = this.getActiveTouches(); dfTouchEventArgs dfTouchEventArg2 = new dfTouchEventArgs(this.control, touches, info.ray); this.control.OnMultiTouch(dfTouchEventArg2); return(true); } if (!this.IsDragging && info.Phase == TouchPhase.Stationary) { if (info.control != this.control) { return(false); } this.control.OnMouseHover(info); return(true); } if ((!this.capture.Contains(info.FingerID) || this.dragState != dfDragDropState.None ? false : info.Phase == TouchPhase.Moved)) { dfDragEventArgs dfDragEventArg2 = info; this.control.OnDragStart(dfDragEventArg2); if (dfDragEventArg2.State == dfDragDropState.Dragging && dfDragEventArg2.Used) { this.dragState = dfDragDropState.Dragging; this.dragData = dfDragEventArg2.Data; return(true); } this.dragState = dfDragDropState.Denied; } if (!(info.control != this.control) || this.capture.Contains(info.FingerID)) { this.control.OnMouseMove(info); return(true); } this.control.OnMouseLeave(info); this.touches.Remove(info.FingerID); return(true); }
/// <summary> /// Processes touch information for a single control /// </summary> /// <param name="info">The touch/raycast data to be processed</param> /// <returns>Returns TRUE if the touch information was processed</returns> public bool Process( TouchRaycast info ) { #region Drag / Drop if( IsDragging ) { // Not interested in any fingers other than the one that // started the drag operation if( !capture.Contains( info.FingerID ) ) return false; // Nothing to do if there's no user action if( info.Phase == TouchPhase.Stationary ) return true; // If the touch was cancelled, raise OnDragEnd event if( info.Phase == TouchPhase.Canceled ) { control.OnDragEnd( new dfDragEventArgs( control, dfDragDropState.Cancelled, dragData, info.ray, info.position ) ); dragState = dfDragDropState.None; touches.Clear(); capture.Clear(); return true; } // If the finger was lifted, attempt drop if( info.Phase == TouchPhase.Ended ) { // Dropped on nothing if( info.control == null || info.control == control ) { control.OnDragEnd( new dfDragEventArgs( control, dfDragDropState.CancelledNoTarget, dragData, info.ray, info.position ) ); dragState = dfDragDropState.None; touches.Clear(); capture.Clear(); return true; } // Dropped on another control var dropArgs = new dfDragEventArgs( info.control, dfDragDropState.Dragging, dragData, info.ray, info.position ); info.control.OnDragDrop( dropArgs ); // If there was no event consumer, or if the event consumer did not // change the state from Dragging (which is not a valid state for // a drop event) then just cancel the operation if( !dropArgs.Used || dropArgs.State != dfDragDropState.Dropped ) { dropArgs.State = dfDragDropState.Cancelled; } // Let the control know that it is no longer being dragged var endArgs = new dfDragEventArgs( control, dropArgs.State, dragData, info.ray, info.position ); endArgs.Target = info.control; control.OnDragEnd( endArgs ); // Clear state dragState = dfDragDropState.None; touches.Clear(); capture.Clear(); return true; } return true; } #endregion #region New touch for this control if( !touches.ContainsKey( info.FingerID ) ) { // Touch is not over control, and is not "captured" by control if( info.control != control ) return false; // Start tracking this finger touches[ info.FingerID ] = info; // See if this is the first touch to be tracked for this control if( touches.Count == 1 ) { // This is the first Touch to be associated with the control control.OnMouseEnter( info ); // If the touch was also started while over the control, // then raise the OnMouseDown event if( info.Phase == TouchPhase.Began ) { capture.Add( info.FingerID ); controlStartPosition = control.transform.position; control.OnMouseDown( info ); // Prevent "click-through" if( Event.current != null ) Event.current.Use(); } return true; } // Switch control to "multi-touch" mode if touch began on control, // otherwise ignore the new touch info if( info.Phase == TouchPhase.Began ) { // Send multi-touch event var activeTouches = getActiveTouches(); var multiTouchArgs = new dfTouchEventArgs( control, activeTouches, info.ray ); control.OnMultiTouch( multiTouchArgs ); } return true; } #endregion #region Previously tracked touch has now ended if( info.Phase == TouchPhase.Canceled || info.Phase == TouchPhase.Ended ) { var phase = info.Phase; var touch = touches[ info.FingerID ]; // Remove the finger from the list of touches touches.Remove( info.FingerID ); if( touches.Count == 0 && phase != TouchPhase.Canceled ) { if( capture.Contains( info.FingerID ) ) { if( canFireClickEvent( info, touch ) ) { if( info.control == this.control ) { if( info.touch.tapCount > 1 ) control.OnDoubleClick( info ); else control.OnClick( info ); } } info.control = this.control; this.control.OnMouseUp( info ); } capture.Remove( info.FingerID ); return true; } else { capture.Remove( info.FingerID ); } if( touches.Count == 1 ) { // Explicitly notify control that multi-touch state has ended control.OnMultiTouchEnd(); return true; } } #endregion #region Multi-touch events // If there is more than one touch active for this control, // then raise the OnMultiTouch event instead of converting // the touch info to mouse events if( touches.Count > 1 ) { var activeTouches = getActiveTouches(); var multiTouchArgs = new dfTouchEventArgs( control, activeTouches, info.ray ); control.OnMultiTouch( multiTouchArgs ); return true; } #endregion // If the touch has not moved, send hover message if( !IsDragging && info.Phase == TouchPhase.Stationary ) { if( info.control == this.control ) { control.OnMouseHover( info ); return true; } return false; } #region See if the control supports (and allows) drag-and-drop var canStartDrag = capture.Contains( info.FingerID ) && dragState == dfDragDropState.None && info.Phase == TouchPhase.Moved; if( canStartDrag ) { // Query the control to see if drag-and-drop is allowed var dragStartArgs = (dfDragEventArgs)info; control.OnDragStart( dragStartArgs ); // If control set State and Used properties to the correct values, // enter drag-and-drop mode if( dragStartArgs.State == dfDragDropState.Dragging && dragStartArgs.Used ) { this.dragState = dfDragDropState.Dragging; this.dragData = dragStartArgs.Data; return true; } // Flag that we've already tried drag and drop this.dragState = dfDragDropState.Denied; } #endregion // Check for mouse leave if( info.control != this.control ) { // If "capture" is not active, fire the OnMouseLeave event if( !capture.Contains( info.FingerID ) ) { info.control = this.control; this.control.OnMouseLeave( info ); this.touches.Remove( info.FingerID ); return true; } } // At this point, the only remaining option is to send OnMouseMove event info.control = this.control; this.control.OnMouseMove( info ); return true; }
public void DragEventProxy( dfControl control, dfDragEventArgs dragEvent ) { callProxyEventHandler( control, dragEvent ); }
void OnDragDrop( dfControl source, dfDragEventArgs args ) { if( allowDrop( args ) ) { args.State = dfDragDropState.Dropped; var otherSlot = args.Data as SpellSlot; var temp = this.spellName; this.Spell = otherSlot.Spell; if( otherSlot.IsActionSlot ) { otherSlot.Spell = temp; } } else { args.State = dfDragDropState.Denied; } args.Use(); }
public void OnDragEnd(dfControl source, dfDragEventArgs args) { isDragging = false; }