Fix reference image drag n drop

Add icon to reference image delete dialog
This commit is contained in:
JannisX11 2023-04-28 20:17:47 +02:00
parent ac41bb4ea3
commit 00b477de2d
2 changed files with 17 additions and 1 deletions

View File

@ -7,6 +7,19 @@ function setupDragHandlers() {
loadImages(files, event)
}
)
Blockbench.addDragHandler(
'reference_image',
{extensions: ['jpg', 'jpeg', 'bmp', 'tiff', 'tif', 'gif'], propagate: true, readtype: 'image', condition: () => !Dialog.open},
function(files, event) {
files.map(file => {
return new ReferenceImage({
source: file.content,
name: file.name || 'Reference'
}).addAsReference(true);
}).last().select();
ReferenceImageMode.activate();
}
)
Blockbench.addDragHandler(
'model',
{extensions: Codec.getAllExtensions},
@ -125,7 +138,7 @@ async function loadImages(files, event) {
} else if (method == 'reference_image') {
files.map(file => {
new ReferenceImage({
return new ReferenceImage({
source: file.content,
name: file.name || 'Reference'
}).addAsReference(true);

View File

@ -520,9 +520,12 @@ class ReferenceImage {
}
async delete(force) {
if (!force) {
let img = new Image();
img.src = this.source;
let result = await new Promise(resolve => Blockbench.showMessageBox({
title: 'data.reference_image',
message: 'message.delete_reference_image',
icon: img,
buttons: ['dialog.confirm', 'dialog.cancel']
}, resolve));
if (result == 1) return;