public EventInfo(EventBase e) { IMouseEvent mouseEvent = e as IMouseEvent; if (mouseEvent != null) { mousePosition = mouseEvent.mousePosition; localMousePosition = mouseEvent.localMousePosition; modifiers = mouseEvent.modifiers; character = '\0'; keyCode = KeyCode.None; } else { IKeyboardEvent keyboardEvent = e as IKeyboardEvent; if (keyboardEvent != null) { character = keyboardEvent.character; keyCode = keyboardEvent.keyCode; modifiers = keyboardEvent.modifiers; mousePosition = Vector2.zero; localMousePosition = Vector2.zero; } } }
public DropdownMenuEventInfo(EventBase e) { IMouseEvent mouseEvent = e as IMouseEvent; bool flag = mouseEvent != null; if (flag) { this.< mousePosition > k__BackingField = mouseEvent.mousePosition; this.< localMousePosition > k__BackingField = mouseEvent.localMousePosition; this.< modifiers > k__BackingField = mouseEvent.modifiers; this.< character > k__BackingField = '\0'; this.< keyCode > k__BackingField = KeyCode.None; } else { IKeyboardEvent keyboardEvent = e as IKeyboardEvent; bool flag2 = keyboardEvent != null; if (flag2) { this.< character > k__BackingField = keyboardEvent.character; this.< keyCode > k__BackingField = keyboardEvent.keyCode; this.< modifiers > k__BackingField = keyboardEvent.modifiers; this.< mousePosition > k__BackingField = Vector2.zero; this.< localMousePosition > k__BackingField = Vector2.zero; } } }
void senEvent(KeyCode keycode, KeybrdEventType evType) { GetAllRootObject(); GetAllComponents(); //Loop over all the interfaces and callthe appropriate function for (int i = 0; i < allTransforms.Count; i++) { GameObject obj = allTransforms[i].gameObject; //Invoke the appropriate interface function if not null IKeyboardEvent itfc = obj.GetComponent <IKeyboardEvent>(); if (itfc != null) { if (evType == KeybrdEventType.keyDown) { itfc.OnKeyDown(keycode); } if (evType == KeybrdEventType.KeyUp) { itfc.OnKeyUP(keycode); } if (evType == KeybrdEventType.down) { itfc.OnKey(keycode); } } } }
private void Init(EventBase evt) { this.eventBaseName = evt.GetType().Name; this.eventTypeId = evt.eventTypeId; this.eventId = evt.eventId; this.triggerEventId = evt.triggerEventId; this.timestamp = evt.timestamp; this.target = evt.target; this.skipElements = evt.skipElements; this.isPropagationStopped = evt.isPropagationStopped; this.isImmediatePropagationStopped = evt.isImmediatePropagationStopped; this.isDefaultPrevented = evt.isDefaultPrevented; IMouseEvent mouseEvent = evt as IMouseEvent; IMouseEventInternal mouseEventInternal = evt as IMouseEventInternal; this.hasUnderlyingPhysicalEvent = (mouseEvent != null && mouseEventInternal != null && mouseEventInternal.triggeredByOS); this.propagationPhase = evt.propagationPhase; this.originalMousePosition = evt.originalMousePosition; this.currentTarget = evt.currentTarget; this.dispatch = evt.dispatch; bool flag = mouseEvent != null; if (flag) { this.modifiers = mouseEvent.modifiers; this.mousePosition = mouseEvent.mousePosition; this.button = mouseEvent.button; this.pressedButtons = mouseEvent.pressedButtons; this.clickCount = mouseEvent.clickCount; } IPointerEvent pointerEvent = evt as IPointerEvent; IPointerEventInternal pointerEventInternal = evt as IPointerEventInternal; this.hasUnderlyingPhysicalEvent = (pointerEvent != null && pointerEventInternal != null && pointerEventInternal.triggeredByOS); bool flag2 = pointerEvent != null; if (flag2) { this.modifiers = pointerEvent.modifiers; this.mousePosition = pointerEvent.position; this.button = pointerEvent.button; this.pressedButtons = pointerEvent.pressedButtons; this.clickCount = pointerEvent.clickCount; } IKeyboardEvent keyboardEvent = evt as IKeyboardEvent; bool flag3 = keyboardEvent != null; if (flag3) { this.character = keyboardEvent.character; this.keyCode = keyboardEvent.keyCode; } ICommandEvent commandEvent = evt as ICommandEvent; bool flag4 = commandEvent != null; if (flag4) { this.commandName = commandEvent.commandName; } }
void Init(EventBase evt) { eventBaseName = evt.GetType().Name; eventTypeId = evt.eventTypeId; eventId = evt.eventId; triggerEventId = evt.triggerEventId; timestamp = evt.timestamp; target = evt.target; skipElements = evt.skipElements; isPropagationStopped = evt.isPropagationStopped; isImmediatePropagationStopped = evt.isImmediatePropagationStopped; isDefaultPrevented = evt.isDefaultPrevented; IMouseEvent mouseEvent = evt as IMouseEvent; IMouseEventInternal mouseEventInternal = evt as IMouseEventInternal; hasUnderlyingPhysicalEvent = mouseEvent != null && mouseEventInternal != null && mouseEventInternal.triggeredByOS; propagationPhase = evt.propagationPhase; originalMousePosition = evt.originalMousePosition; currentTarget = evt.currentTarget; dispatch = evt.dispatch; if (mouseEvent != null) { modifiers = mouseEvent.modifiers; mousePosition = mouseEvent.mousePosition; button = mouseEvent.button; clickCount = mouseEvent.clickCount; // TODO: Scroll Wheel //delta = mouseEvent.delta; } IKeyboardEvent keyboardEvent = evt as IKeyboardEvent; if (keyboardEvent != null) { character = keyboardEvent.character; keyCode = keyboardEvent.keyCode; } ICommandEvent commandEvent = evt as ICommandEvent; if (commandEvent != null) { commandName = commandEvent.commandName; } }
private bool CanStopManipulation(IKeyboardEvent e) { foreach (var filter in activeFilters) { if (e.keyCode == filter.key) { return(true); } } return(false); }
/// <summary> /// 注册按键处理 /// </summary> /// <param name="handler">Handler.</param> public void AddKeyHandler(IKeyboardEvent handler) { if (handler == null) { return; } if (!_KeyboardDelegates.Contains(handler)) { _KeyboardDelegates.Add(handler); } }
/// <summary> /// 移除按键处理 /// </summary> /// <param name="handler">Handler.</param> public void RemoveKeyHandler(IKeyboardEvent handler) { if (handler == null) { return; } if (!_KeyboardDelegates.Contains(handler)) { return; } _KeyboardDelegates.Remove(handler); }
private bool CanStartManipulation(IKeyboardEvent evt) { activeFilters.Clear(); foreach (var filter in filters) { if (filter.Matches(evt)) { activeFilters.Add(filter); } } if (activeFilters.Count > 0) { return(true); } return(false); }
private bool HasModifiers(IKeyboardEvent e) { if (((modifiers & EventModifiers.Alt) != 0 && !e.altKey) || ((modifiers & EventModifiers.Alt) == 0 && e.altKey)) { return(false); } if (((modifiers & EventModifiers.Control) != 0 && !e.ctrlKey) || ((modifiers & EventModifiers.Control) == 0 && e.ctrlKey)) { return(false); } if (((modifiers & EventModifiers.Shift) != 0 && !e.shiftKey) || ((modifiers & EventModifiers.Shift) == 0 && e.shiftKey)) { return(false); } return(((modifiers & EventModifiers.Command) == 0 || e.commandKey) && ((modifiers & EventModifiers.Command) != 0 || !e.commandKey)); }
void Init(EventBase evt) { var type = evt.GetType(); eventBaseName = EventDebugger.GetTypeDisplayName(type); eventTypeId = evt.eventTypeId; eventId = evt.eventId; triggerEventId = evt.triggerEventId; timestamp = evt.timestamp; target = evt.target; skipElements = evt.skipElements; isPropagationStopped = evt.isPropagationStopped; isImmediatePropagationStopped = evt.isImmediatePropagationStopped; isDefaultPrevented = evt.isDefaultPrevented; var mouseEvent = evt as IMouseEvent; var mouseEventInternal = evt as IMouseEventInternal; hasUnderlyingPhysicalEvent = mouseEvent != null && mouseEventInternal != null && mouseEventInternal.triggeredByOS; propagationPhase = evt.propagationPhase; originalMousePosition = evt.originalMousePosition; currentTarget = evt.currentTarget; dispatch = evt.dispatch; if (mouseEvent != null) { modifiers = mouseEvent.modifiers; mousePosition = mouseEvent.mousePosition; button = mouseEvent.button; pressedButtons = mouseEvent.pressedButtons; clickCount = mouseEvent.clickCount; var wheelEvent = mouseEvent as WheelEvent; if (wheelEvent != null) { delta = wheelEvent.delta; } } var pointerEvent = evt as IPointerEvent; if (pointerEvent != null) { var pointerEventInternal = evt as IPointerEventInternal; hasUnderlyingPhysicalEvent = pointerEvent != null && pointerEventInternal != null && pointerEventInternal.triggeredByOS; modifiers = pointerEvent.modifiers; mousePosition = pointerEvent.position; button = pointerEvent.button; pressedButtons = pointerEvent.pressedButtons; clickCount = pointerEvent.clickCount; } IKeyboardEvent keyboardEvent = evt as IKeyboardEvent; if (keyboardEvent != null) { character = keyboardEvent.character; keyCode = keyboardEvent.keyCode; } ICommandEvent commandEvent = evt as ICommandEvent; if (commandEvent != null) { commandName = commandEvent.commandName; } INavigationEvent navigationEvent = evt as INavigationEvent; if (navigationEvent != null) { deviceType = navigationEvent.deviceType; if (evt is NavigationMoveEvent nme) { navigationDirection = nme.direction; } } }
public bool Matches(IKeyboardEvent e) { return(key == e.keyCode && HasModifiers(e)); }