-
Notifications
You must be signed in to change notification settings - Fork 107
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
SDA-4481: Add Fix to image cannot be copied #2109
Conversation
@@ -376,12 +376,17 @@ export class ContextMenuBuilder { | |||
* Adds "Copy Image" and "Copy Image URL" items when `src` is valid. | |||
*/ | |||
public addImageItems(menu, menuInfo) { | |||
const target = this.getWebContents(); | |||
const current = this.getWebContents(); |
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.
const current = this.getWebContents(); | |
const focusedWindow = BrowserWindow.getFocusedWindow() as ICustomBrowserWindow; | |
if(focusedWindow && focusedWindow.winName !== apiName.mainWindowName) { | |
focusedWindow.webContents.send('copy-to-clipboard', menuInfo.srcURL); | |
} else { | |
focusedWindow.webContents.copyImageAt(menuInfo.x, menuInfo.y); | |
} |
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.
This way you ensure that window is the main window and not a child window
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.
I suggest using focused window to check main,
remaining logic might not be different due to getWebcontent using exact same as BrowserWindow focus if current webcontent is not found
e226cba
to
dda7245
Compare
const copyImage = new MenuItem({ | ||
label: this.stringTable.copyImage(), | ||
click: (_e) => { | ||
if (focusedWindow && focusedWindow.winName === apiName.mainWindowName) { | ||
current?.send('copy-to-clipboard', menuInfo.srcURL); |
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.
current?.send('copy-to-clipboard', menuInfo.srcURL); | |
focusedWindow.webContents.send('copy-to-clipboard', menuInfo.srcURL); |
dda7245
to
87e27ef
Compare
Description
The fix targets to remove regression on cannot copy image of Workspace / Popout. This fix does not include pasting from workspace/popout to 3rd parties, currently tech limitation.
Related PRs
Demo
TinyTake.by.MangoApps-11-03-2024-04-56-25.mp4