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

Feature request: allow assigning a different color to the right mouse button #99

Open
KR155E opened this issue Jan 18, 2024 · 3 comments

Comments

@KR155E
Copy link

KR155E commented Jan 18, 2024

Usually, image manipulation programs allow to assign different colors to the left and right mouse buttons. It would be great if this was also supported by dotting. Right now, only a single color can be set, which is drawn with both left or right mouse buttons.

@hunkim98
Copy link
Owner

I did not quite understand this feature request. From what I know, the color selection needs to be programmed by the user (the developer can freely set the brush color logic using the brushColor prop in Dotting) Maybe you could implement your own mouse logic for your program for the right mouse button? Please notify me if I understood it wrong.

@KR155E
Copy link
Author

KR155E commented Jan 22, 2024

Thank you @hunkim98, that did the trick. I did not think of this possibility.

For reference, here's my solution. I wrapped Dotting in a div that sets the brush color to a secondary color on right mouse button click (onContextMenu), and sets the brush color back to a primary color when the mouse button is lifted (onMouseUp).

Bildschirmfoto 2024-01-22 um 12 26 56

@KR155E KR155E closed this as completed Jan 22, 2024
@KR155E
Copy link
Author

KR155E commented Jan 22, 2024

I spoke too soon unfortunately. Above solution works fine when right-clicking and dragging the mouse to draw multiple pixels at once, but when right-clicking without dragging the mouse to draw only a single pixel, then it does not. Apparently, the pixel is drawn to the canvas and only after that, the onContextMenu listener on the wrapping div is executed.

I tried a few alternative ways like using onMouseDown instead of onContextMenu, or setting the eventlistener directly on the dottingRef using addCanvasElementEventListener. But it was the same problem every time.

Perhaps, this needs to be adressed by Dotting after all.

@KR155E KR155E reopened this Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants