Skip to content

Commit

Permalink
Removes the requirement of pressing the Shift key when changing a val…
Browse files Browse the repository at this point in the history
…ue with the mouse wheel.
  • Loading branch information
PhaserEditor2D committed Feb 6, 2024
1 parent 955a6d8 commit 5bb0201
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Depth order commands now works with Mac keyboard with a numeric pad, in its default config.
* Fixes bug with opening multiple context menus.
* Color Picker shows realtime preview of the color.
* Allows changing numeric values with the mouse wheel, while pressing Shift.
* Allows changing numeric values with the mouse wheel.
* Allows changing numeric values with the Up/Down keys. If Shift is pressed, it increments it by 10.

## v3.66.0 - Jan 11, 2024
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,40 @@ namespace colibri.ui.controls.properties {

if (increment !== undefined) {

text.addEventListener("wheel", e => {
text.addEventListener("focusout", e => {

text.removeAttribute("__editorWheel");

if (!text.hasAttribute("__editorWheel")) {
const initText = text.getAttribute("__editorInitText");

text.setAttribute("__editorInitText", text.value);
if (text.value !== initText) {

text.dispatchEvent(new CustomEvent("change", {
detail: {
initText
}
}));
}
});

text.addEventListener("focusin", () => {

text.setAttribute("__editorInitText", text.value);
});

text.addEventListener("wheel", e => {

text.setAttribute("__editorWheel", "1");

if (e.shiftKey && document.activeElement === text) {
if (document.activeElement === text) {

e.preventDefault();

const delta = increment * Math.sign(e.deltaY);

text.value = (parseFloat(text.value) + delta).toString();

text.dispatchEvent(new CustomEvent("preview"));
text.dispatchEvent(new Event("preview"));
}
});

Expand Down Expand Up @@ -164,29 +180,11 @@ namespace colibri.ui.controls.properties {

text.value = (parseFloat(text.value) + delta).toString();

text.dispatchEvent(new Event("change"));
text.dispatchEvent(new Event("preview"));

e.preventDefault();
}
});

text.addEventListener("keyup", e => {

if (text.getAttribute("__editorWheel") === "1") {

e.preventDefault();

text.removeAttribute("__editorWheel");

text.value = parseFloat(text.value).toString();

text.dispatchEvent(new CustomEvent("change", {
detail: {
initText: text.getAttribute("__editorInitText")
}
}));
}
});
}

return text;
Expand Down

0 comments on commit 5bb0201

Please sign in to comment.