-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Is there a way to get the input element when clicked? #102
Comments
The menu options ( |
Thanks, that works. |
Turns out it doesn't quite work as intended. The |
Then I don't know. You could try opening a feature request on https://github.com/electron/electron to include the DOM element in the |
Alright, I'll do that. Thanks for replying. I'll close the issue. |
It's not work |
@amanharwara You can accomplish this by capturing the click in the render process and using For example, in your render process (browser context): const ipcRenderer = window.require('electron').ipcRenderer
$(document).mousedown(event => {
if( event.which == 3) {
//this is a right click, so electron-context-menu will be appearing momentarily...
let textBoxClicked = $(event.target).closest('.MY-TEXTBOX')
if(textBoxClicked.length) ipcRenderer.send('right-click/' + $(textBoxClicked).attr('id') )
}
}) then in your electron process: let clickedElemId = null
//this will run before the electron-context-menu function:
electron.ipcMain.on('right-click', (event, elemId) => {
if(!elemId) {
clickedElemId = null
return
}
clickedElemId = docId
})
require('electron-context-menu')({
showSearchWithGoogle : false,
append: (defaultActions, params, browserWindow) => [
{
label: 'Add Text to Box',
// Now we can use this logic to show the menu item, or add context to it, etc:
visible: _.isString(clickedElemId),
click () {
//and send a response back if u need:
mainWindow.webContents.send('add-text-to-box')
}
}]
})
} |
If you're landing here because your custom context menus override electron-context-menu on Mac, but don't show on Windows, it might be as simple as adding an |
I want to add certain text into a textbox when the user clicks an item in the context menu. For this, it will be necessary to get the textbox element itself when clicked. Is this possible somehow?
The text was updated successfully, but these errors were encountered: