Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blender-like NumericInput controls #121

Open
kungfooman opened this issue Jul 26, 2021 · 0 comments
Open

Blender-like NumericInput controls #121

kungfooman opened this issue Jul 26, 2021 · 0 comments

Comments

@kungfooman
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Copying/pasting/defaulting a value is not quickly possible

Describe the solution you'd like
In Blender you can just hover a value and press ctrl+c/ctrl+v/backspace

Proof of Concept

console.clear();
hoveredInput = null; // PCUI element
lastCopy = 0.0;
inputs = [...document.getElementsByTagName("input")];
inputs.forEach(input => {
  input.onmouseleave = function(event) {
    hoveredInput = null;
  }
  input.onmouseenter = function(event) {
    hoveredInput = event.target?.ui;
  }
});
document.onkeydown = function (event) {
  if (hoveredInput) {
    if (event.key == 'Backspace') {
      hoveredInput.value = 0; // Math.random();
      event.preventDefault();
    } else if (event.ctrlKey && event.key == 'c') {
      lastCopy = hoveredInput.value;
      event.preventDefault();
      //console.log("copy value", lastCopy);
    } else if (event.ctrlKey && event.key == 'v') {
      hoveredInput.value = lastCopy;
      //console.log("paste value", lastCopy);
      event.preventDefault();
    }
  }
  //console.log(event);
}

NumericInputExtraControls

Code is just a PoC, it would require proper integration into at least the NumericInput class and/or wherever it makes sense.

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

No branches or pull requests

1 participant