electron-userland / electron-spellchecker

Implement spellchecking, correctly
MIT License
237 stars 83 forks source link

Needs two clicks to get spell checker context menu #98

Open snene opened 6 years ago

snene commented 6 years ago

electron: 1.7.8 electron-spellchecker: 1.1.2

Thanks for the example provided, I got spell checker to work in my application inside the webview. It detects the wrongly spelled words and marks them. But when I right click on the wrong word, I don't see the menu entries for the spell checker. But when I right click the second time, I see them.

I am also using electron-context-menu to add other context menu entries.

I am wondering why do I need to click twice to get the spell checker menu entries. Any pointers? Thanks a lot!

Nantris commented 6 years ago

It's likely you are inadvertently creating a context menu somewhere else. For example when using Chrome developer tools I have an inspect element option on the first click, and have to click again to get the normal context menu.

WilliamHolmes commented 6 years ago

@snene @Slapbox Do you think it's possible to add these spelling mistake corrections to the initial context menu (first click) ?

snene commented 6 years ago

@WilliamHolmes Yes, the solution is to not display your application's context menu when the spell checker is supposed to display its for a misspelled word. e.g. for your context menu add a check like following

// Build right-click context menu when webview's ready
  require('electron-context-menu')({
    window: webview,
    // If spell checker context menu is going to be displayed don't show ours
    shouldShowMenu: (event, params) => !(params.isEditable && params.misspelledWord && params.misspelledWord.length),
WilliamHolmes commented 6 years ago

Thanks @snene i’ll try that. Im still trying to figure out how to change the electron browser context menu (copy, paste, etc.) language as that is where the spelling corrections are placed.

WilliamHolmes commented 6 years ago

@snene @Slapbox image

Any ideas how to change that electron browser context menu to another language?

Nantris commented 6 years ago

Unfortunately no. Have you downloaded the source code and searched for the string "Search with Google" ?

That's where I'd start. If you find out how to do this, please be sure to come back and update us!

WilliamHolmes commented 6 years ago

Thanks for he reply. I’ve opened a issue/question to the wider community for some feed back. https://github.com/electron-userland/electron-spellchecker/issues/114

WilliamHolmes commented 6 years ago

FYI Found it. https://github.com/electron-userland/electron-spellchecker/issues/114#issuecomment-384394832