Skip to content

feat(ui): add number input dragging - #917

Merged
aarthificial merged 5 commits into
motion-canvas:mainfrom
jmaen:number-input-dragging
Jan 12, 2024
Merged

feat(ui): add number input dragging#917
aarthificial merged 5 commits into
motion-canvas:mainfrom
jmaen:number-input-dragging

Conversation

@jmaen

@jmaen jmaen commented Jan 11, 2024

Copy link
Copy Markdown
Contributor

Add a new NumberInput component that supports dragging to edit numbers. When hovering over the input, the cursor is a left-right arrow to indicate the dragging option. For the dragging behavior, the PointerLock API is used.

In order to edit the value manually via keyboard input, users can click the component without dragging. Dragging is then disabled and the cursor switches to a regular text cursor, allowing text selection. Up and down arrow keys are also supported through the regular <input type="number"/> element.

The new NumberInput also supports min, max and step properties for input via the arrow keys and via dragging.

Closes #799

input-dragging.mov

@jmaen
jmaen requested a review from aarthificial as a code owner January 11, 2024 00:52

@aarthificial aarthificial left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add the following handler to the input as well:

onKeyDown={event => {
  if (event.key === 'Enter') {
    inputRef.current.blur();
  }
  if (event.key === 'Escape') {
    inputRef.current.value = currentValue.toString();
    inputRef.current.blur();
  }
}}

Comment thread packages/ui/src/components/controls/NumberInput.tsx Outdated
Comment thread packages/ui/src/components/controls/NumberInput.tsx Outdated
Comment thread packages/ui/src/components/controls/NumberInput.tsx Outdated
Comment thread packages/ui/src/components/controls/NumberInput.tsx Outdated
Comment thread packages/ui/src/components/controls/NumberInputSelect.tsx Outdated
Comment thread packages/ui/src/components/controls/NumberInput.tsx Outdated
jmaen and others added 2 commits January 11, 2024 17:36
Co-authored-by: Jacob <64662184+aarthificial@users.noreply.github.com>
@jmaen

jmaen commented Jan 11, 2024

Copy link
Copy Markdown
Contributor Author

I think I adressed all your requested changes. Apparently the pipeline failed to build, but the error seems to have occured in core which is not something I worked on.

@aarthificial
aarthificial merged commit 1b5c232 into motion-canvas:main Jan 12, 2024
@aarthificial

Copy link
Copy Markdown
Contributor

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dragging MetaFieldView Input

2 participants