On 02/20/2017 03:08 AM, dan hitt wrote:

Some of the constructors of Button (gtk/Button.d) let you specify a delegate to receive the action when a button is clicked on.

However, those delegates seem to only take a Button as an argument, and not the event that triggered the press.

Sometimes having the event is useful, for telling if it was a shift-click or control-click.

Now, i'm getting around this by just creating a button only with a label and no delegate, and then manually attaching a callback with Signals for "button-press-event" where the callback does get the event. This works, and is not too lengthy, so i'm not complaining, but would appreciate knowing if it can be skipped. (For example, when you are in a delegate that has responded to a click, can you detect and query the last event somehow? And is it easy to do?)

This is all using 3.5.1.

TIA for any info!

The Button constructor connects the delegate to the clicked event, that
is executed when the button is pressed and released.

If you want more control on how the event is handled you should indeed
use addOnButtonPress or one of the others depending on your use case.

As far as i know you cant access the event data of the separate pressed
and release events from the clicked handler.