M
M
Mikhail2017-10-07 20:59:23
C++ / C#
Mikhail, 2017-10-07 20:59:23

C# How to perform an action if the right mouse button is pressed?

You need to perform an action label.text = "Зажата"
If the right mouse button is pressed and the cursor is over the element.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kuznetsov, 2017-10-08
@DarkRaven

If this needs to be controlled on a specific element, then you need the MouseDown event.
Almost all UI controls have this event. Just subscribe to it (to MouseUp too, for the reverse action).
Additionally, you can look here - https://msdn.microsoft.com/ru-ru/library/system.wi...
If you need globally (no matter what element, just understand if any mouse button is pressed) - there is such a library, https://github.com/gmamaladze/globalmousekeyhook . There is an example there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question