Skip to content

Commit

Permalink
Quick keyboard samples
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Aug 1, 2023
1 parent 7e015a0 commit 4a887b7
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
50 changes: 49 additions & 1 deletion ShanedlerSamples/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,55 @@ public partial class App : Application
public App()
{
InitializeComponent();
}

protected override Window CreateWindow(IActivationState activationState)
{
return new KeyboardCapableWindow(new AppShell());
}


class KeyboardCapableWindow : Window
{
public KeyboardCapableWindow()
{
}

public KeyboardCapableWindow(Page page) : base(page)
{
page.HandlerChanged += OnPageHandlerChanged;
}

void OnPageHandlerChanged(object sender, EventArgs e)
{

if (sender is IView view && view.Handler is IPlatformViewHandler pvh)
{
#if WINDOWS
pvh.PlatformView.KeyDown += (X, Y) =>
{
};
pvh.PlatformView.KeyUp += (X, Y) =>
{
};
pvh.PlatformView.PreviewKeyDown += (X, Y) =>
{
};

pvh.PlatformView.PreviewKeyUp += (X, Y) =>
{
};
#endif
}
}

MainPage = new AppShell();
protected override void OnHandlerChanged()
{
base.OnHandlerChanged();
}
}
}
12 changes: 12 additions & 0 deletions ShanedlerSamples/Platforms/iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
using Foundation;
using UIKit;

namespace ShanedlerSamples;

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();


public override void PressesBegan(NSSet<UIPress> presses, UIPressesEvent evt)
{
base.PressesBegan(presses, evt);
}

public override void PressesEnded(NSSet<UIPress> presses, UIPressesEvent evt)
{
base.PressesEnded(presses, evt);
}
}

0 comments on commit 4a887b7

Please sign in to comment.