-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ILauncher launch events and intercept #15674
base: master
Are you sure you want to change the base?
Conversation
Provide a common base class and make platform implementation inherit it Turn PlatformInfoPage in ControlCatalog into more general Platform page and expose Uri launcher for testing
11e7620
to
1d6cb34
Compare
You can test this PR using the following package version. |
|
@cla-avalonia agree |
In my opinion this isn't the correct approach. ILauncher is clean and simple as is and works for most apps. If you need to customize a service, then you need to provide your own ILauncher implementation. That's the whole beauty of using services. Inside your implementation you can do what you want first, raise events, then invoke the system ILauncher. That said, I'm not sure we have a way of registering service overrides. We probably should support that. |
I agree with @robloo. Looking at your original issue:
Typically, such scenario could be solved by having a special routed event on a Hyperlink control. Like, |
Thanks for your feedback. If I'm not mistaken, you can't do any such thing. Since V11 the service locator ( More specifically for this case, the launcher implementations are hardwired for the platform-specific Regarding a custom hyperlink control with a special routed event: Absolutely, that's still doable. If you think this is beyond the scope of Avalonia core, that's fine. Let me know, what direction this should take, if any. |
That point was about a service in your application logic, not a replacement for Avalonia service. |
So condensing a few ideas:
|
What does the pull request do?
Introduces new events on
ILauncher
implementations that triggers when a Uri/file launch occurs. The event arguments provide information about the Uri/file and include a property to cancel the default invocation.What is the current behavior?
ILauncher
invokes the platform handling of Uri/file directly. No event is raised.What is the updated/expected behavior with this PR?
Desired Enhancements
Notification Event: We want to be notified by an event when a URI/file launch occurs.
Interception and Custom Handling: We aim to intercept the call and handle the URI/file launch in a customizable way.
How was the solution implemented (if it's not obvious)?
The PR adds two events to
ILauncher
:UriLaunching
andFileLaunching
. It also adds an abstract base class implementing the event handling. ExistingILauncher
implementations are updated to derive from that common base instead.The PR also turns the
PlatformInfoPage
in theControlCatalog
into more general Platform page and exposes Uri launcher for testing (opens Avalonia website). Additional platform features (think MAUI essentials) might be added here in the future?!Fixed issues
See #15673