How to capture both left and right mouse click on ClickableWidget?

  • 7 Replies
  • 56 Views
I have a tgui::Canvas object, to which I connected events using "MousePressed":

auto canvas = tgui::Canvas::create();
canvas->connect("MousePressed", [this]() { /*...*/ });


But it seems the event is only triggered on left mouse click, not on right mouse click.

Is there any way to trigger on both?

*

texus

  • *****
  • 1463
    • View Profile
    • Texus's Blog
Re: How to capture both left and right mouse click on ClickableWidget?
« Reply #1 on: 02 September 2019, 18:45:52 »
The name MousePressed has been in use before right clicks were supported at all, which is why the name doesn't make it clear that it only refers to left mouse clicks.
Support for right mouse clicks is currently extremely limited. Widgets know when the right mouse is pressed with the internal rightMousePressed and rightMouseReleased functions, but ListView is currently the only widget with a RightClicked callback.

What are you trying to do exactly? Would you need a callback on the actual click, or already when the right mouse button goes down?

Re: How to capture both left and right mouse click on ClickableWidget?
« Reply #2 on: 02 September 2019, 19:14:04 »
I need the callback when mouse goes down and then also when mouse goes up.

I can simulate it from outside code, I just wanted to know whether there is easy way to do it or maybe error on my side.

*

texus

  • *****
  • 1463
    • View Profile
    • Texus's Blog
Re: How to capture both left and right mouse click on ClickableWidget?
« Reply #3 on: 02 September 2019, 19:18:45 »
There currently is no easy way.
I could perhaps add RightMousePressed, RightMouseReleased and RightClicked callbacks to ClickableWidget though.

Re: How to capture both left and right mouse click on ClickableWidget?
« Reply #4 on: 03 September 2019, 16:47:34 »
It would be certainly convenient for me, but question is whether there is some greater need for this feature.

*

texus

  • *****
  • 1463
    • View Profile
    • Texus's Blog
Re: How to capture both left and right mouse click on ClickableWidget?
« Reply #5 on: 03 September 2019, 19:13:20 »
The ability to right click came up once or twice in the past, so I guess it wouldn't hurt to add callbacks to ClickableWidget and Panel. I'll do that soon.

*

texus

  • *****
  • 1463
    • View Profile
    • Texus's Blog
Re: How to capture both left and right mouse click on ClickableWidget?
« Reply #6 on: 03 September 2019, 20:21:57 »
RightMousePressed, RightMouseReleased and RightClicked signals have been added to ClickableWidget and Panel widgets.

Re: How to capture both left and right mouse click on ClickableWidget?
« Reply #7 on: 03 September 2019, 22:10:15 »
Wow, hats off for you for such speed