User avatar
Gazoo
Topic Author
Posts: 36
Joined: 14 Sep 2022, 10:00
Contact:

Testing for left button click while in a MouseMove Event

05 Oct 2022, 12:09

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
 
User avatar
Gazoo
Topic Author
Posts: 36
Joined: 14 Sep 2022, 10:00
Contact:

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

10 Oct 2022, 10:21

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
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

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

11 Oct 2022, 10:38

Glad to know it is fixed, closing this then.

Who is online

Users browsing this forum: Google [Bot] and 16 guests