Skip to content

Commit c64b670

Browse files
committed
ID retrieval based on focusItem when initializing CSV import component
1 parent a1990be commit c64b670

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

gui-js/apps/minsky-electron/src/app/events/electron.events.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ ipcMain.handle(events.NEW_SYSTEM, async () => {
219219
ipcMain.handle(
220220
events.IMPORT_CSV,
221221
async (event, payload: MinskyProcessPayload) => {
222-
const { mouseX, mouseY } = payload;
223-
224-
const itemInfo = await CommandsManager.getItemInfo(mouseX, mouseY);
222+
const itemInfo = await CommandsManager.getFocusItemInfo();
225223
if(itemInfo) {
226224
CommandsManager.importCSV(itemInfo, true);
227225
} else {

gui-js/apps/minsky-electron/src/app/managers/CommandsManager.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,18 @@ export class CommandsManager {
7272
return null;
7373
}
7474

75+
return await this.getCurrentItemInfo();
76+
}
77+
78+
static async getFocusItemInfo(): Promise<CanvasItem> {
79+
await minsky.canvas.setItemFromItemFocus();
80+
return await this.getCurrentItemInfo();
81+
}
82+
83+
static async getCurrentItemInfo() {
7584
const classType = (await this.getCurrentItemClassType()) as ClassType;
7685
const id = await minsky.canvas.item.id();
77-
86+
7887
if(this.isFalseResult(id)) {
7988
return null;
8089
}
@@ -85,7 +94,7 @@ export class CommandsManager {
8594
}
8695

8796
const itemInfo: CanvasItem = { classType, id, displayContents };
88-
return itemInfo;
97+
return itemInfo;
8998
}
9099

91100
static async selectVar(x: number, y: number): Promise<boolean> {

gui-js/libs/shared/src/lib/backend/minsky.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ export class Canvas extends CppClass {
463463
async selectVar(a1: number,a2: number): Promise<boolean> {return this.$callMethod('selectVar',a1,a2);}
464464
async setDefaultPlotOptions(): Promise<void> {return this.$callMethod('setDefaultPlotOptions');}
465465
async setItemFocus(a1: Item): Promise<void> {return this.$callMethod('setItemFocus',a1);}
466+
async setItemFromItemFocus(): Promise<void> {return this.$callMethod('setItemFromItemFocus');}
466467
async showDefiningVarsOnCanvas(): Promise<void> {return this.$callMethod('showDefiningVarsOnCanvas');}
467468
async showPlotsOnTab(): Promise<void> {return this.$callMethod('showPlotsOnTab');}
468469
async surface(): Promise<ecolab__cairo__Surface> {return this.$callMethod('surface');}

model/canvas.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,10 @@ namespace minsky
992992
}
993993
}
994994

995-
995+
void Canvas::setItemFromItemFocus()
996+
{
997+
item = itemFocus;
998+
}
996999
}
9971000

9981001
CLASSDESC_ACCESS_EXPLICIT_INSTANTIATION(minsky::EventInterface);

model/canvas.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ namespace minsky
291291
}
292292

293293
void applyDefaultPlotOptions();
294+
295+
void setItemFromItemFocus();
294296
};
295297
}
296298

0 commit comments

Comments
 (0)