Skip to content
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

Support back mouse button #6996

Closed
Pablohn26 opened this issue Aug 26, 2016 · 24 comments
Closed

Support back mouse button #6996

Pablohn26 opened this issue Aug 26, 2016 · 24 comments

Comments

@Pablohn26
Copy link

@Pablohn26 Pablohn26 commented Aug 26, 2016

  • Electron version:1.3.1
  • Operating system:Fedora 24

It seems Event: ‘app-command’ is only available in Windows. Would be possible to add Linux support of it?

@zcbenz
Copy link
Member

@zcbenz zcbenz commented Aug 29, 2016

There is no app-command on Linux, the buttons on mouses are translated to key events depending on your machine's configuration. Can you try whether the button works in Chrome browser? And if it is working can you use the xev tool to get what key event the button is translated to?

@MarshallOfSound
Copy link
Member

@MarshallOfSound MarshallOfSound commented Aug 29, 2016

GPMDP uses a native node module for forward and back mouse buttons on linux that we made ourselves.

https://github.com/jostrander/mouse-forward-back

Does this fulfill your needs?

@Pablohn26
Copy link
Author

@Pablohn26 Pablohn26 commented Aug 29, 2016

I have run xev -event button with next output

root:1@/tmp# xev -event button
Outer window is 0x6c00001, inner window is 0x6c00002

ButtonPress event, serial 25, synthetic NO, window 0x6c00001,
    root 0xd4, subw 0x6c00002, time 75696468, (46,32), root:(143,592),
    state 0x10, button 9, same_screen YES

ButtonRelease event, serial 25, synthetic NO, window 0x6c00001,
    root 0xd4, subw 0x6c00002, time 75696756, (46,32), root:(143,592),
    state 0x10, button 9, same_screen YES

ButtonPress event, serial 25, synthetic NO, window 0x6c00001,
    root 0xd4, subw 0x6c00002, time 75697284, (46,32), root:(143,592),
    state 0x10, button 8, same_screen YES

ButtonRelease event, serial 25, synthetic NO, window 0x6c00001,
    root 0xd4, subw 0x6c00002, time 75697556, (46,32), root:(143,592),
    state 0x10, button 8, same_screen YES

button 9 is forward button and button 8 is back button.

And yes, it is working on Google Chrome and chromium.

@jonathansampson
Copy link

@jonathansampson jonathansampson commented Apr 2, 2017

I came to the same results as @Pablohn26.

brave/browser-laptop#5620 (comment)

@ioan-ungurean
Copy link

@ioan-ungurean ioan-ungurean commented Oct 6, 2017

There is now a year and a half and no progress on this?

@jaewonha
Copy link

@jaewonha jaewonha commented Mar 15, 2018

came here from vs code not supporting back key navigation...
please someone take care of this issue...!

@verner-lall
Copy link

@verner-lall verner-lall commented Apr 25, 2018

Almost 2 years for something seemingly simple. Please?

@SocksPls
Copy link

@SocksPls SocksPls commented Apr 25, 2018

Anything? This is the only thing stopping me using brave as my main browser on all of my computers.

@premek
Copy link

@premek premek commented Apr 25, 2018

How should this be implemented?

  • Should it emulate app-command windows event on linux? (no need to change the apps and it will start automatically working)
  • use a different api for listening to mouse buttons? Apps would have to implement it differently on win/linux
  • use mouse-forward-back package as suggested above? That would also have to be implemented in apps differently for linux

Also, how about OSX?

@Aetherall
Copy link

@Aetherall Aetherall commented Jul 29, 2018

I am not an electron developer so maybe I am saying pure nonsense :)

but maybe it is solvable by the adapter paradigm,
where there is an "OSX mouse event adapter", "Linux mouse event adapter" and "Windows mouse event adapter" and the correct one is chosen on compile time?

@coreybruce
Copy link

@coreybruce coreybruce commented Sep 11, 2018

it already is supported in Linux and it's really annoying, I keep accidentally pressing the button on my mouse, how do I disable the back button?!

@codebytere
Copy link
Member

@codebytere codebytere commented Sep 24, 2018

Given that this has bene solved in userland by modules like mouse-forward-back, and that this isn't currently on our roadmap, i'm going to go ahead and label this a wontfix. However, should someone determine a workable solution we would be very open to accepting a PR!

@coreybruce
Copy link

@coreybruce coreybruce commented Sep 24, 2018

If you guys want to disable the back button from working on your web page in electron just use this script in the body

onLoad="noBack();" onpageshow="if (event.persisted) noBack();"

e.g

<body onLoad="noBack();" onpageshow="if (event.persisted) noBack();" onUnload="" style="margin: 0 auto;">
</body>

@jonathansampson
Copy link

@jonathansampson jonathansampson commented Sep 30, 2018

@coreybruce Your code lacks the function itself. Is noBack already defined as a global somewhere in Electron? Also, why would you want to do this?

@coreybruce
Copy link

@coreybruce coreybruce commented Oct 1, 2018

@coreybruce Your code lacks the function itself. Is noBack already defined as a global somewhere in Electron? Also, why would you want to do this?

I have a gaming application called Gamer World and I it is really annoying when I accidentally press the back button my mouse in the middle of a game and it goes back a page.

here is a link to the Gitlab repo

https://gitlab.com/coreybruce/Gamerworld-App

@britalmeida
Copy link

@britalmeida britalmeida commented Oct 7, 2018

Can you communicate better and make it easier for software using electron to setup the navigate back/forwards correctly?
Currently, neither VSCode or Spotify on Linux have the functionality working.

@JoseFMP
Copy link

@JoseFMP JoseFMP commented Oct 20, 2018

As @britalmeida mentioned. Why wouldn't this be used in VSCode on Linux? Would be great to propagate the achievement :)

@coreybruce
Copy link

@coreybruce coreybruce commented Oct 20, 2018

What does VSCode have to do with Electron tho @JoseFMP?

@codebytere
Copy link
Member

@codebytere codebytere commented Oct 20, 2018

@coreybruce: vscode is an electron app 😉

@coreybruce
Copy link

@coreybruce coreybruce commented Oct 21, 2018

@codebytere Oh right I see

@mikelpr
Copy link

@mikelpr mikelpr commented Apr 17, 2019

this is crazy. why is there an API difference for something so basic between windows and linux and why should each app implement back and forward specifically for linux and not share code with windows and macos?

@Yanpas
Copy link

@Yanpas Yanpas commented Apr 26, 2019

Seems like mac users are still lacking this.
https://electronjs.org/docs/api/browser-window#event-app-command-windows-linux

Why not introduce separate event 'navigation' or 'crossplatform-command' event? This is VERY ugly workaround.

@luxalpa
Copy link

@luxalpa luxalpa commented Dec 8, 2019

Isn't electron supposed to make cross platform development easier? Then why suddenly separate this behavior between platforms?

@RattlingAmigo
Copy link

@RattlingAmigo RattlingAmigo commented Oct 17, 2020

With some javascript and html, we can make like browsers button (<) (>) for every platform.
Making below lines of the code on top of the page, with some css would be the work around.

Code:

<input type=button name="back" value="Go Back" onclick="history.back();">
<input type=button name="forward" value="Go Forward"onclick="history.forward();">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet