Skip to content

Commit

Permalink
fix bad merge
Browse files Browse the repository at this point in the history
fix menu item behavior with keys
  • Loading branch information
tomlm committed Nov 30, 2024
1 parent a371dfb commit 3221292
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
9 changes: 2 additions & 7 deletions src/Consolonia.Core/Drawing/RenderTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ void IDrawingContextLayerImpl.Blit(IDrawingContextImpl context)

bool IDrawingContextLayerImpl.CanBlit => true;

public IDrawingContextImpl CreateDrawingContext(bool useScaledDrawing)
{
if (useScaledDrawing)
throw new NotImplementedException($"Consolonia doesn't support useScaledDrawing");
return new DrawingContextImpl(_consoleWindow);
}

public bool IsCorrupted => false;


Expand Down Expand Up @@ -151,6 +144,8 @@ private void RenderToDevice()

public IDrawingContextImpl CreateDrawingContext(bool useScaledDrawing)
{
if (useScaledDrawing)
throw new NotImplementedException($"Consolonia doesn't support useScaledDrawing");
return new DrawingContextImpl(_consoleWindow);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,16 @@ private void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Handled) return;

if (e.Source is MenuItem)
{
return;
}

if (e.Key == Key.Escape)
{
// if there is a overlay popup, close it
var overlay = ((Visual)sender).FindDescendantOfType<OverlayPopupHost>();
var overlay = sender as OverlayPopupHost ??
((Visual)sender).FindDescendantOfType<OverlayPopupHost>();
if (overlay != null)
{
// it will have a popup as the parent.
Expand All @@ -141,7 +147,7 @@ private void OnKeyDown(object sender, KeyEventArgs e)
}

//see FocusManager.GetFocusManager
IInputElement current = TopLevel.GetTopLevel((Visual)sender)!.FocusManager!.GetFocusedElement();
IInputElement current = TopLevel.GetTopLevel((Visual)sender)?.FocusManager?.GetFocusedElement();

if (e.KeyModifiers != KeyModifiers.None)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private void OnShowDialog(object sender, Avalonia.VisualTreeAttachmentEventArgs
OneMoreButton.AttachedToVisualTree += OnButtonAttached;
}

private void OnButtonAttached(object? sender, VisualTreeAttachmentEventArgs e)
private void OnButtonAttached(object sender, VisualTreeAttachmentEventArgs e)
{
OneMoreButton.AttachedToVisualTree -= OnButtonAttached;
OneMoreButton.Focus();
Expand Down
2 changes: 0 additions & 2 deletions src/Tests/Consolonia.Gallery.Tests/ComboBoxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ await UITest.AssertHasText("Pick an Item",
await UITest.AssertHasText("Inline Item 3");
await UITest.KeyInput(Key.Down);
await UITest.AssertHasText("Inline Item 4");
await UITest.KeyInput(Key.Down);
await UITest.AssertHasText("Inline Item 4");
await UITest.KeyInput(Key.Tab, Key.Down);
await UITest.AssertHasText("Hello");
}
Expand Down

0 comments on commit 3221292

Please sign in to comment.