Place assets by dragging them from the panel into the view
The context menu entry is gone; dragging replaces it entirely. The drop target is the view under the pointer, not the active tab, so the same gesture works for scenes and for container templates. While dragging, an outline shows the footprint the object will have plus a crosshair on its origin, turning red when the drop would be refused. Preview and command share one function (placementRejection), so the outline cannot promise something the drop then rejects. A left-press used to select the list row immediately. Since the container tab follows the selection, it switched to the very container being dragged and every drop would have nested it inside itself. The list now selects on release without a drag: picking something up is not the same as choosing it.
This commit is contained in:
1 parent
14562cf157
commit
75d377af39
18 files changed
+545
-77
No files matched your search
@@ -174,6 +174,33 @@ function makeTools({ cdp, projectId, baseUrl, consoleLog, check, shotPrefix }) {
|
||||
await sleep(150);
|
||||
};
|
||||
|
||||
/**
|
||||
* Drags an asset out of the Assets panel onto a point in a view – the only way to place one
|
||||
* since the context menu lost its entry. By id, not by text: the container picker shows the
|
||||
* same name as the row. Unlike `drag()` it presses and moves in separate events on purpose,
|
||||
* because the panel turns the press into a drag only once it has travelled.
|
||||
*/
|
||||
const dragAsset = async (assetId, x, y, steps = 8) => {
|
||||
const from = await json(`__gm.assetRow(${JSON.stringify(assetId)})`);
|
||||
if (!from) throw new Error(`no asset row for "${assetId}" – is the panel scrolled past it?`);
|
||||
await mouse('mouseMoved', from.x, from.y);
|
||||
await mouse('mousePressed', from.x, from.y);
|
||||
for (let i = 1; i <= steps; i++) {
|
||||
await mouse(
|
||||
'mouseMoved',
|
||||
from.x + ((x - from.x) * i) / steps,
|
||||
from.y + ((y - from.y) * i) / steps,
|
||||
'left',
|
||||
{
|
||||
buttons: 1,
|
||||
},
|
||||
);
|
||||
await sleep(16);
|
||||
}
|
||||
await mouse('mouseReleased', x, y);
|
||||
await sleep(200);
|
||||
};
|
||||
|
||||
// --- keyboard ------------------------------------------------------------------------------
|
||||
|
||||
const keyEvent = (type, name, modifiers) => {
|
||||
@@ -291,6 +318,7 @@ function makeTools({ cdp, projectId, baseUrl, consoleLog, check, shotPrefix }) {
|
||||
click,
|
||||
clickText,
|
||||
drag,
|
||||
dragAsset,
|
||||
press,
|
||||
holdKey,
|
||||
typeText,
|
||||
|
||||
Reference in new issue
Block a user