private void OnScrollWheel(InputAction.CallbackContext context) { EKeyboardModifier modifier = InputUtils.GetCurrentKeyboardModifier(); int scrollDirection = Math.Sign(context.ReadValue <Vector2>().y); if (scrollDirection != 0 && noteArea.IsPointerOver) { // Scroll horizontal in NoteArea with no modifier if (modifier == EKeyboardModifier.None) { noteArea.ScrollHorizontal(scrollDirection); } // Zoom horizontal in NoteArea with Ctrl if (modifier == EKeyboardModifier.Ctrl) { noteArea.ZoomHorizontal(scrollDirection); } // Scroll vertical in NoteArea with Shift if (modifier == EKeyboardModifier.Shift) { noteArea.ScrollVertical(scrollDirection); } // Zoom vertical in NoteArea with Ctrl + Shift if (modifier == EKeyboardModifier.CtrlShift) { noteArea.ZoomVertical(scrollDirection); } } }
private void UpdateInputToScrollAndZoom(EKeyboardModifier modifier) { // Scroll with arroy keys if (Input.GetKeyUp(KeyCode.LeftArrow) && modifier == EKeyboardModifier.None && !InputFieldHasFocus()) { noteArea.ScrollHorizontal(-1); } if (Input.GetKeyUp(KeyCode.RightArrow) && modifier == EKeyboardModifier.None && !InputFieldHasFocus()) { noteArea.ScrollHorizontal(1); } // Zoom and scroll with mouse wheel int scrollDirection = Math.Sign(Input.mouseScrollDelta.y); if (scrollDirection != 0 && noteArea.IsPointerOver) { // Scroll horizontal in NoteArea with mouse wheel if (modifier == EKeyboardModifier.None) { noteArea.ScrollHorizontal(scrollDirection); } // Zoom horizontal in NoteArea with Ctrl + mouse wheel if (modifier == EKeyboardModifier.Ctrl) { noteArea.ZoomHorizontal(scrollDirection); } // Scroll vertical in NoteArea with Shift + mouse wheel if (modifier == EKeyboardModifier.Shift) { noteArea.ScrollVertical(scrollDirection); } // Zoom vertical in NoteArea with Ctrl + Shift + mouse wheel if (modifier == EKeyboardModifier.CtrlShift) { noteArea.ZoomVertical(scrollDirection); } } }
public void Update() { bool noModifier = !Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftAlt); bool ctrlExclusive = Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftAlt); bool shiftExclusive = !Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftAlt); bool ctrlShiftExclusive = Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftAlt); int scrollDirection = Math.Sign(Input.mouseScrollDelta.y); if (Input.GetKeyUp(KeyCode.Space)) { songEditorSceneController.TogglePlayPause(); } if (scrollDirection != 0 && noteArea.IsPointerOver) { // Scroll horizontal in NoteArea with mouse wheel if (noModifier) { noteArea.ScrollHorizontal(scrollDirection); } // Zoom horizontal in NoteArea with Ctrl + mouse wheel if (ctrlExclusive) { noteArea.ZoomHorizontal(scrollDirection); } // Scroll vertical in NoteArea with Shift + mouse wheel if (shiftExclusive) { noteArea.ScrollVertical(scrollDirection); } // Zoom vertical in NoteArea with Ctrl + Shift + mouse wheel if (ctrlShiftExclusive) { noteArea.ZoomVertical(scrollDirection); } } }
private void UpdateInputToScrollAndZoom(EKeyboardModifier modifier) { // Scroll with arroy keys if (Input.GetKeyUp(KeyCode.LeftArrow) && modifier == EKeyboardModifier.None) { noteArea.ScrollHorizontal(-1); } if (Input.GetKeyUp(KeyCode.RightArrow) && modifier == EKeyboardModifier.None) { noteArea.ScrollHorizontal(1); } // Zoom horizontal with Ctrl+'+' and Ctrl+'-' // Note: On my keyboard, the plus button has KeyCode.Equals but I don't know why. bool isPlusKeyUp = Input.GetKeyUp(KeyCode.Plus) || Input.GetKeyUp(KeyCode.KeypadPlus) || Input.GetKeyUp(KeyCode.Equals); bool isMinusKeyUp = Input.GetKeyUp(KeyCode.Minus) || Input.GetKeyUp(KeyCode.KeypadMinus); if (isPlusKeyUp && modifier == EKeyboardModifier.Ctrl) { noteArea.ZoomHorizontal(1); } if (isMinusKeyUp && modifier == EKeyboardModifier.Ctrl) { noteArea.ZoomHorizontal(-1); } // Zoom vertical with Ctrl+Shift+'+' and Ctrl+Shift+'-' if (isPlusKeyUp && modifier == EKeyboardModifier.CtrlShift) { noteArea.ZoomVertical(1); } if (isMinusKeyUp && modifier == EKeyboardModifier.CtrlShift) { noteArea.ZoomVertical(-1); } // Zoom and scroll with mouse wheel int scrollDirection = Math.Sign(Input.mouseScrollDelta.y); if (scrollDirection != 0 && noteArea.IsPointerOver) { // Scroll horizontal in NoteArea with mouse wheel if (modifier == EKeyboardModifier.None) { noteArea.ScrollHorizontal(scrollDirection); } // Zoom horizontal in NoteArea with Ctrl + mouse wheel if (modifier == EKeyboardModifier.Ctrl) { noteArea.ZoomHorizontal(scrollDirection); } // Scroll vertical in NoteArea with Shift + mouse wheel if (modifier == EKeyboardModifier.Shift) { noteArea.ScrollVertical(scrollDirection); } // Zoom vertical in NoteArea with Ctrl + Shift + mouse wheel if (modifier == EKeyboardModifier.CtrlShift) { noteArea.ZoomVertical(scrollDirection); } } }