microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.29k stars 675 forks source link

Proposal: Add a MathInputBox control #5288

Open winston-de opened 3 years ago

winston-de commented 3 years ago

Proposal: Add a MathInputBox control

Summary

This proposal is to provide a control that allows developers to provide users with a rich experience for creating, editing, and viewing math equations for all input methods.

Rationale

Scope

Capability Priority
This proposal will add a MathInputControl that devs can add to their apps Must
The MathInputControl will give users a rich equation editing experience and commands, for example auto closing parenthesis, converting "\sqrt" to √ Must
The MathInputControl will provide an ink to math experience with a pen, for example showing a ink input panel for math when tapped with a pen similar to TextBox behavior Must
The MathInputControl will allow users with screen readers to easily understand the MathInputBox content (possibly by reading equations the same way they would be pronounced, eg "x^2" -> "x squared") Must
This proposal will add an input scope for "math", so that the windows touch keyboard can provide an enhanced equation input experience for tablets (eg math autocomplete and symbols) Must
The MathInputControl will allow developers to specify the output format (eg LaTeX, raw text) Could

Important Notes

Possible code for a basic graphing scenario:

<StackPanel Orientation="Vertical>
    <MathInputBox Format="LaTeX" Text="y = x ^ { 2 }" InputChanged="MathInputBox_InputChanged"/>
    <controls:GraphControl />
</StackPanel>
void MathInputBox_InputChanged(object sender, MathInputChangedEventArgs e)
{
  GraphEquation(e.Output);
}

///<summary> Graphs the given equation</summary>
/// <param name="equation">The equation to graph in LaTeX format</param>
private void GraphEquation(string equation) 
{
    // magic
}

Open Questions

mdtauk commented 3 years ago

I think I made a similar proposal, when the NumberBox was being proposed.

Calculator is currently working on moving their UI code to C# whilst making their core code that handles the calculations, a C++ WinRT component.

So maybe when that work is done, WinUI could include that Core and create a TextBox/NumberBox with a Calculator flyout?

image https://github.com/microsoft/calculator/issues/453#issuecomment-483872523

winston-de commented 3 years ago

This proposal isn't for a calculator control, but for a control designed for entering (complex) math equations. Something similar to what OneNote has.

https://user-images.githubusercontent.com/59544401/123497256-46603480-d5e1-11eb-9b0e-f51282a7b1ee.mp4

You're idea is pretty cool though, and probably could be achieved using the LaunchUriForResultsAsync function.