Page 1 of 1

Testing for left button click while in a MouseMove Event

Posted: 05 Oct 2022, 12:09
by Gazoo
Hey y'all,

I'm working on gaining a greater understand of WPF, xaml, and NoesisGui. To that end I'm trying to drag and drop a single red rectangle in canvas element, as per this tutorial I've found online:
https://www.youtube.com/watch?v=THV5BW5WW_o

I am aware of the behaviors-based approach outline in the Noesis Tutorial and sample code, but there are quite a few other xaml concepts in that tutorial which I don't fully understand, so I thought it worthwhile to start a lot simpler.

I've hooked up NoesisGui to register mouse events and I have following xaml setup:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="400">

    <Border BorderBrush="black" BorderThickness="3">
        <Canvas>
            <Rectangle
                x:Name="RedRectangle"
                Canvas.Left="50"
                Canvas.Top="50"
                Width="50"
                Height="50"
                Fill="Red" />
        </Canvas>
    </Border>

</Grid>
with the following native code:
	auto rectangle = mXamlGrid->FindName<Noesis::Button>( "RedRectangle" );

	rectangle->MouseMove() += [&]( Noesis::BaseComponent* sender, Noesis::MouseEventArgs const& args )
	{
		if (args.leftButton == Noesis::MouseButtonState::MouseButtonState_Pressed)
		{
			int horse = 2;

			//Noesis::DragDrop::DoDragDrop( rectangle, nullptr, Noesis::DragDropEffects::DragDropEffects_Move );
		}
	};
With the Visual studio debugger I can tell that the MouseMove event is triggered properly. However, the args.leftButton appears to never evaluate to true, despite me verifying that I do pass left clicks on to NoesisGui. Any ideas as to where this is all going side-ways or perhaps how I can debug this further?

Cheers,
Gazoo

[Solved] Re: Testing for left button click while in a MouseMove Event

Posted: 10 Oct 2022, 10:21
by Gazoo
I'd forgotten that LibCinder differentiates between a mouse moving while a button is not clicked, and a mouse moving while a button *is* clicked. After I hooked up both the mouseMove *and* mouseDrag event to NoesisGui's standard mouse move function, I got the result I was expecting.

Cheers,
Gazoo

Re: Testing for left button click while in a MouseMove Event

Posted: 11 Oct 2022, 10:38
by sfernandez
Glad to know it is fixed, closing this then.