Skip to content

Blender-like NumericInput controls #121

@kungfooman

Description

@kungfooman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions