dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.27k stars 1.76k forks source link

Interactive objects on Canvas as in WPF #8235

Open janseris opened 2 years ago

janseris commented 2 years ago

Description

As far as I know, MAUI canvas can only draw but the elements are not interactive or they do not exist as UI objects. Something like that has been possible in WPF for 10+ years.

https://stackoverflow.com/questions/7556493/how-do-i-recognize-a-mouse-click-on-a-line

private void myCanvas_Loaded(object sender, RoutedEventArgs e)
{
            Line line = new Line();
            //line is a real UI object with event handlers
            line.MouseDown += new MouseButtonEventHandler(line_MouseDown);
            line.MouseUp   += new MouseButtonEventHandler(line_MouseUp);

            line.Stroke = Brushes.Black;
            line.StrokeThickness = 2;
            line.X1 = 30; line.X2 = 80;
            line.Y1 = 30; line.Y2 = 30;

            myCanvas.Children.Add(line);
}

//when tap on ends, turn black
void line_MouseUp(object sender, MouseButtonEventArgs e)
{
            // Change line colour back to normal 
            ((Line)sender).Stroke = Brushes.Black;
}

//when tapped on, become red
void line_MouseDown(object sender, MouseButtonEventArgs e)
{
            // Change line Colour to something
            ((Line)sender).Stroke = Brushes.Red;
}

These objects can be composed etc. When will it come to MAUI? Thank you

Public API Changes

Shapes on canvas are UI elements with events, not just rendered pixels

Intended Use-Case

Interactive complicated shapes where computing click coordinates (or handling different events!) is very complicated. (all other than rectangle, point, line and circle) Example use case: interactive graphical shapes over image background. For example a situation on construction site which shows localities with problems and various items are displayed over the situation image and also miniatures of images are displayed and interactive points are localized into the image. Also the whole canvas shall be zoomable - zoom into any place and interact with objects in that part of the situation image.

janseris commented 2 years ago

In Windows Forms using System. Graphics, calculating hits is easily achieved as well, using GraphicsPath objects which provide required methods.

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.