Giter VIP home page Giter VIP logo

Comments (9)

rabbitism avatar rabbitism commented on July 25, 2024

Is this really related to ursa or semi?

from avalonia.

KevinYinHHU avatar KevinYinHHU commented on July 25, 2024

Is this really related to ursa or semi?

Thank you for your response to the question!
This issue is not related to Semi or Ursa
After encountering this issue in my project, I listed all the components that may be related to the problem. Finally, I tested it on the website(https://play.avaloniaui.net/) and found that the issue is related to Avalonia, not Semi or Ursa

from avalonia.

x-a-a-d avatar x-a-a-d commented on July 25, 2024

maybe the same issue as #11665 ?

from avalonia.

KevinYinHHU avatar KevinYinHHU commented on July 25, 2024

maybe the same issue as #11665 ?
Yes, it's the same issue as # 11665, but there is currently no solution, which has a significant impact on the mobile phone project! If the issue cannot be resolved, the mobile project will be forced to pause.

from avalonia.

Gillibald avatar Gillibald commented on July 25, 2024

Feel free to debug it

from avalonia.

timunie avatar timunie commented on July 25, 2024

Closing as duplicate of #11665

@KevinYinHHU it doesn't help to open new issues for known ones. This doesn't speed up anything...

from avalonia.

KevinYinHHU avatar KevinYinHHU commented on July 25, 2024

Closing as duplicate of #11665

@KevinYinHHU it doesn't help to open new issues for known ones. This doesn't speed up anything...

Yes, a similar problem has already occurred, look forward to a solution.

from avalonia.

KevinYinHHU avatar KevinYinHHU commented on July 25, 2024

Feel free to debug it

Thanks.

from avalonia.

KevinYinHHU avatar KevinYinHHU commented on July 25, 2024

During my exploration of the Avalonia framework, I've encountered limitations in mobile browser environments that extend beyond just issues with TextBox controls; file open and save dialogues also fail to function properly. These challenges appear rooted in browser compatibility rather than any inherent design flaws in Avalonia itself. To address these difficulties, I've devised a temporary solution intended to offer guidance to others facing similar hurdles:

Overview of the Solution
In a browser context, Avalonia essentially behaves as a responsive Canvas component, not unlike other elements on a webpage. By leveraging the [JSImports] and [JSExports] mechanisms, we can invoke native input controls (such as Input or TextArea) to enhance Avalonia's functionality in a manner akin to building a conventional webpage. Although this method adds an extra layer of complexity potentially affecting user experience, it ensures that Avalonia remains usable in mobile browsers.

Implementation Details
Technological Choice: Given my limited expertise in frontend technologies, I opted for LayUI as a supporting tool. This is a lightweight front-end library that includes a variety of basic controls and has a compact size of approximately 350KB.
Custom AKBTextBox: I developed a custom control named AKBTextBox. When detected in a mobile browser environment, this control is set to read-only. By listening for the PointerReleased event, I trigger the layui.prompt dialog from LayUI, capturing user input and synchronizing it back to the AKBTextBox.

public class AKBTextBox : Avalonia.Controls.TextBox
{
protected override Type StyleKeyOverride => typeof(TextBox);
public AKBTextBox()
{
if (MainPanel.Current.IsMobile)
{
this.IsReadOnly = true;
this.PointerReleased += AKBTextBox_PointerReleased;
}
}
private async void AKBTextBox_PointerReleased(object? sender, Avalonia.Input.PointerReleasedEventArgs e)
{
if (OperatingSystem.IsBrowser())
{
string? result = null;
string title=this.Watermark?? "Please enter:";
if (this.AcceptsReturn)
{
result = await BrowserImports.PromptAsync(title, this.Text??"", 2);
}
else
{
result = await BrowserImports.PromptAsync(title, this.Text ?? "", 0);
}
if (result == null) return;
this.Text = result;
}

}

}

Efficacy Verification: Through a series of tests, this approach proved highly effective, achi

e1142e9bd85a4ccf1029ef31ce0216c6.mp4

eving the desired results.
Solution Expansion
Based on this logic, theoretically, we can call upon any native browser control to enrich the capabilities of Avalonia in mobile applications. This strategy isn't confined to text input but can be extended to a broader range of interactive scenarios, significantly enhancing the potential of Avalonia on mobile devices.

from avalonia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.