Simple Avalonia app (.net core 3 preview4) deployed to a Raspberry Pi. The UI works: can enter text and press enter on buttons once in focus (using keyboard tab).
However a mouse click does not bring TextBox into focus nor fire a Button event.
The same code deployed to Ubuntu linux 18.04 works with a mouse.
What am I missing here?
I had the same problem with no touch or mouse input on Raspbian X11.
Debugging the Avalonia.X11 project I found that some structures are hard coded for arm64 and so the offsets are wrong for Raspbian which is arm32. This is why it works for Ubuntu arm64.
In XIStructs.cs change all occurrences of ulong Serial to IntPtr Serial; this occurs in three places, struct XIDeviceEvent, struct XIDeviceChangedEvent and struct XIEvent. Rebuild the Avalonia.X11 project and link your program with the generated Avalonia.X11.dll and it should work on Raspbian.
Incidentally for the maintainers, looking at the code I don't think the XiEventType.XI_DeviceChanged event will ever fire as the XI2Manager.AddWindow method will disable the event when the window is added; i.e. it is enabled in the Init method and then disabled again by the subsequent call to the AddWindow method.
The version 0.8.1 already has this fix?
0.8.1 contains a very specific set of backported fixes. You can use nightly builds, they are usually stable enough.
Version 0.8.1. does not work, but how to get this nightly build, I did everything by this link: https://github.com/AvaloniaUI/Avalonia/wiki/Using-nightly-build-feed but no Alpha versions.
bt version 0.8.1. does not work I mean, mouse does not work on Pi
@mariorancic01
Check for the CI versions, if you are using visual studio make sure the checkbox "include prerelease" are checked.
I'm using this on my .csproj :
<PackageReference Include="Avalonia" Version="0.8.999-cibuild0003137-beta" />
<PackageReference Include="Avalonia.Desktop" Version="0.8.999-cibuild0003137-beta" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.8.999-cibuild0003137-beta" />
<PackageReference Include="Avalonia.X11" Version="0.8.999-cibuild0003137-beta" />
<PackageReference Include="Avalonia.LinuxFramebuffer" Version="0.8.999-cibuild0003137-beta" />
and is working
OK, after I checked "Include Prerelease" I was able to do update with prerelease versions but I still can't use mouse on Raspberry PI Linux. :(
I have same problem, out-of-the-box simple .NET core MVVM Avalonia application as created by the (latest version of the) VS 2019 extension. Add a Button and TextBox, publish to the Pi running Raspbian. Application renders properly but does not respond to mouse/keyboard. No button clicks, can't click in TextBox to get focus.
Reading this thread, using pre-release CI builds (shown below) to get mouse and keyboard working.
With latest bits, now get compile erorr: Run( ) is not a method on Application class.
Poking around in source and seeing that Run( ) has been refactored in the latest CI builds to use application lifetime approach. Not seeing any documentation (yet) about how to use the latest source.
No idea if this is correct, but it now works! I get keyboard and mouse input on the Pi.
Any pointers on the right way to bootstrap the app after the recent source refactor?
private static void AppMain( ) {
var window = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
var lifetime = new ClassicDesktopStyleApplicationLifetime(app);
app.ApplicationLifetime = lifetime;
lifetime.MainWindow = window;
lifetime.Start( args );
}
Not seeing any documentation (yet) about how to use the latest source.
https://github.com/AvaloniaUI/Avalonia/wiki/Application-lifetimes
Excellent thanks for the pointer @kekekeks
Didn't see a different wiki for nightly builds and didn't realize some of the docs were being updated "in place"
As expected, works with the updated app lifetime bootstrap code.
We usually keep the Breaking changes up to date with the current master.
This code:
private static void AppMain( ) {
var window = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
var lifetime = new ClassicDesktopStyleApplicationLifetime(app);
app.ApplicationLifetime = lifetime;
lifetime.MainWindow = window;
lifetime.Start( args );
}
worked for me too. Now I have mouse on my PI too. Thank you @volleynerd and @kekekeks
Most helpful comment
0.8.1 contains a very specific set of backported fixes. You can use nightly builds, they are usually stable enough.