mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-21 01:13:37 +08:00
Add cursor tooltip API
This commit is contained in:
parent
a5753c2c39
commit
1f0ed593e3
@ -216,7 +216,6 @@
|
||||
cursor: default;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (max-device-width: 640px) {
|
||||
#quick_message_box {
|
||||
bottom: 26px;
|
||||
@ -224,6 +223,24 @@
|
||||
padding: 6px;
|
||||
}
|
||||
}
|
||||
#cursor_tooltip {
|
||||
position: absolute;
|
||||
z-index: 101;
|
||||
max-width: 250px;
|
||||
width: fit-content;
|
||||
line-height: 18px;
|
||||
padding: 2px 8px;
|
||||
margin-top: 10px;
|
||||
margin-left: 9px;
|
||||
background-color: var(--color-bright_ui);
|
||||
color: var(--color-bright_ui_text);
|
||||
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);;
|
||||
overflow-wrap: break-word;
|
||||
white-space: pre-line;
|
||||
cursor: default;
|
||||
pointer-events: none;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.uv_message_box {
|
||||
position: absolute;
|
||||
margin-left: auto;
|
||||
|
16
js/api.js
16
js/api.js
@ -167,6 +167,22 @@ const Blockbench = {
|
||||
}
|
||||
return new deletableToast(notification);
|
||||
},
|
||||
setCursorTooltip(text) {
|
||||
if (!Interface.cursor_tooltip) {
|
||||
Interface.cursor_tooltip = Interface.createElement('div', {id: 'cursor_tooltip'});
|
||||
}
|
||||
if (text) {
|
||||
Interface.cursor_tooltip.textContent = text;
|
||||
if (!Interface.cursor_tooltip.parentNode) {
|
||||
document.body.append(Interface.cursor_tooltip);
|
||||
Interface.cursor_tooltip.style.left = mouse_pos.x + 'px';
|
||||
Interface.cursor_tooltip.style.top = mouse_pos.y + 'px';
|
||||
}
|
||||
} else {
|
||||
Interface.cursor_tooltip.textContent = '';
|
||||
Interface.cursor_tooltip.remove();
|
||||
}
|
||||
},
|
||||
showStatusMessage(message, time) {
|
||||
Blockbench.setStatusBarText(tl(message))
|
||||
setTimeout(function() {
|
||||
|
@ -547,6 +547,11 @@ function setupInterface() {
|
||||
document.addEventListener('mousemove', event => {
|
||||
mouse_pos.x = event.clientX;
|
||||
mouse_pos.y = event.clientY;
|
||||
|
||||
if (Interface.cursor_tooltip?.textContent) {
|
||||
Interface.cursor_tooltip.style.left = mouse_pos.x + 'px';
|
||||
Interface.cursor_tooltip.style.top = mouse_pos.y + 'px';
|
||||
}
|
||||
})
|
||||
updateInterface()
|
||||
}
|
||||
|
@ -1002,7 +1002,7 @@
|
||||
Undo.cancelEdit();
|
||||
}
|
||||
function displayDistance(number) {
|
||||
Blockbench.setStatusBarText(trimFloatNumber(number));
|
||||
Blockbench.setCursorTooltip(trimFloatNumber(number));
|
||||
}
|
||||
function extendTransformLineOnAxis(long, axis) {
|
||||
let axisNumber = getAxisNumber(axis);
|
||||
@ -1593,7 +1593,7 @@
|
||||
|
||||
extendTransformLine(false);
|
||||
|
||||
Blockbench.setStatusBarText();
|
||||
Blockbench.setCursorTooltip();
|
||||
|
||||
if (Modes.id === 'edit' || Modes.id === 'pose' || Toolbox.selected.id == 'pivot_tool') {
|
||||
if (Toolbox.selected.id === 'resize_tool') {
|
||||
|
Loading…
Reference in New Issue
Block a user