AndreasEnscape
Topic Author
Posts: 22
Joined: 01 Aug 2017, 07:37

InputBindings mouse gestures missing?

06 Oct 2017, 11:40

Greetings all,
following this Document https://www.noesisengine.com/docs/Gui.C ... orial.html, I want to implement a command reacting to a right click or left double click, as it is common in WPF.
However, while the code in line with the above mentioned example works
        <ToggleButton Height="120" VerticalAlignment="Center" ...
                      Command="{Binding Path=MyMouseClickCommand}" CommandParameter="testtext"/>
 
anything using a WPF like mouse binding (right click, double click) fails completely, the command method never ever gets called, neither using "MouseAction" nor "Gesture"
        <ToggleButton Height="120" VerticalAlignment="Center" >
            <ToggleButton.InputBindings>
                <MouseBinding MouseAction="RightClick"
                              Command="{Binding Path=MyMouseRightClickCommand}"
                              CommandParameter="Bla"/>
            </ToggleButton.InputBindings>
        </ToggleButton>
Is this functionality implemented at all? If not, how can I realize commands with mouse actions such as the above ones?

I do NOT want a MouseDblBlick="..." solution with dependency objects/properties....

Thanks in advance for assistance,
Andy

EDIT: Important is, that I need to bind to something else than a button, such as a StackPanel....
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: InputBindings mouse gestures missing?

06 Oct 2017, 18:20

Hi,

Mouse input bindings are not implemented yet, only key bindings are available right now. Could you please create a ticket in our bugtracker so we can add them in a future release?

As we found very common the need to connect via XAML a RoutedEvent to a Command we are thinking of including the following attached behavior to NoesisGUI: https://gist.github.com/s-fernandez-v/5 ... ce428808bd.

It would allow doing what you want like this (CommandParameter attached property can be added easily):
<ToggleButton Height="120" VerticalAlignment="Center"
    EventToCommand.Event="MouseRightButtonDown"
    EventToCommand.Command="{Binding MyMouseRightClickCommand}"
    EventToCommand.CommandParameter="Bla">
You could add that EventToCommand code to your project as a workaround until we correctly implement MouseBindings.
 
nikobarli
Posts: 180
Joined: 26 Apr 2017, 06:23

Re: InputBindings mouse gestures missing?

08 Oct 2017, 13:26

As we found very common the need to connect via XAML a RoutedEvent to a Command we are thinking of including the following attached behavior to NoesisGUI: https://gist.github.com/s-fernandez-v/5 ... ce428808bd.
There is one drawback of this approach, that you can only bind one event inside an element (i.e. you cannot bind MouseDown and MouseUp at the same time).

I prefer the approach using Markup Extension as we previously discussed here: viewtopic.php?f=3&t=1150
 
AndreasEnscape
Topic Author
Posts: 22
Joined: 01 Aug 2017, 07:37

Re: InputBindings mouse gestures missing?

09 Oct 2017, 09:26

Imho i would follow the MS approach, having <MouseBinding...> and <KeyBinding...> tags. First of all you can have multiple of them and would thus not end up having the problem nikobarli described, second of all it maintains compatibility....

I will file a bugtracer report and link this discussion.

Regards,
Andy
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: InputBindings mouse gestures missing?

10 Oct 2017, 00:32

MouseBindings will be implemented in Noesis, so this should probably be the best option to connect mouse events to commands.
But the EventToCommand attached properties, or the extension @nikobarli was talking about could still be very interesting when dealing with other events.
I think both approaches are compatible and complementary.

Who is online

Users browsing this forum: blackbone, jsantos, Semrush [Bot] and 9 guests