-
-
Notifications
You must be signed in to change notification settings - Fork 62
Add "Import stock variables" context menu item for Godley icons #575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
16dfc5c
68fa3ae
68f8b1b
666fe8a
3fe0c9a
d669455
adf7d8a
8fb0036
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -651,6 +651,22 @@ export class ContextMenuManager { | |||||||||||
| const rowColButtonsChecked = await godley.buttonDisplay(); | ||||||||||||
| const editorModeChecked = await godley.editorMode(); | ||||||||||||
|
|
||||||||||||
| // build stock import menu for this column | ||||||||||||
|
|
||||||||||||
| const stockImportMenuItems=[]; | ||||||||||||
| { | ||||||||||||
|
||||||||||||
| { | |
| { | |
| // Convert from canvas coordinates (where this.x is relative to the icon center) | |
| // to Godley-local coordinates (where 0 is the left edge of the icon). | |
| // Adding 0.5*width shifts the origin from the center to the left edge. |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing spaces around '=' operators. Should be 'let x = ...', 'let col = ...', and 'let importOptions = ...' for consistent code formatting.
| let importOptions=await godley.editor.matchingTableColumnsByCol(col); | |
| let importOptions = await godley.editor.matchingTableColumnsByCol(col); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing row0 check: menu should only be enabled when clicking on stock column headers.
According to the PR objectives, the "Import stock variables" menu should be "enabled only when right-clicking over a Godley icon's stock column header." The current code builds the import menu for any click location on the GodleyIcon without verifying the user clicked on row0 (the stock variable header row).
Consider checking the click type before building the menu:
const editorModeChecked = await godley.editorMode();
- // build stock import menu for this column
-
const stockImportMenuItems=[];
- {
+ // Only build import menu if clicking on row0 (stock column header)
+ const clickType = await godley.editor.clickTypeZoomed(this.x - await godley.x() + 0.5 * await godley.width(),
+ this.y - await godley.y() + 0.5 * await godley.height());
+ if (clickType === "row0") {
let x=this.x-await godley.x()+0.5*await godley.width();
let col=await godley.editor.colXZoomed(x);
let importOptions=await godley.editor.matchingTableColumnsByCol(col);
for (let v of importOptions)
stockImportMenuItems.push({
label: v,
click: (item) => {
godley.editor.importStockVarByCol(item.label, col);
},
});
}This ensures the menu is context-sensitive as intended.
Committable suggestion skipped: line range outside the PR's diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In practical testing, so long as the import menu item was restricted to columns rather than just row 0, it was fine, since it is a context menu, rather than a right mouse click action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@highperformancecoder, thank you for the clarification and for testing this! I understand now—since this is a context menu for the entire Godley icon (not a row0-specific right-click), restricting the import functionality by column is sufficient and provides the appropriate context-sensitive behavior. Your practical testing confirms this works well.
I appreciate you explaining the distinction between a context menu approach and a right-click action. This makes sense given the overall UI design.
✏️ Learnings added
Learnt from: highperformancecoder
PR: highperformancecoder/minsky#575
File: gui-js/apps/minsky-electron/src/app/managers/ContextMenuManager.ts:654-668
Timestamp: 2025-10-27T05:57:05.870Z
Learning: For Godley icon context menus in `gui-js/apps/minsky-electron/src/app/managers/ContextMenuManager.ts`, the "Import stock variables" menu item is restricted by column (using the clicked x-coordinate to determine the column) rather than being limited to row0 clicks only. This column-based restriction is sufficient for the context menu approach, as confirmed by practical testing.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after '=' operator. Should be 'const stockImportMenuItems = [];' to follow consistent spacing conventions.