Merge branch 'master' of https://github.com/MatterHackers/MatterControl
This commit is contained in:
commit
14c4c61a9c
3 changed files with 39 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2017, John Lewin
|
||||
Copyright (c) 2019, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -29,7 +29,6 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
|
@ -42,6 +41,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
private bool mouseInBounds = false;
|
||||
|
||||
protected ThemeConfig theme;
|
||||
private bool hasKeyboardFocus;
|
||||
|
||||
public SimpleButton(ThemeConfig theme)
|
||||
{
|
||||
|
|
@ -49,6 +49,8 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
this.HoverColor = theme.SlightShade;
|
||||
this.MouseDownColor = theme.MinimalShade;
|
||||
this.Margin = 0;
|
||||
|
||||
this.TabStop = true;
|
||||
}
|
||||
|
||||
public Color HoverColor { get; set; } = Color.Transparent;
|
||||
|
|
@ -81,6 +83,17 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
this.Invalidate();
|
||||
}
|
||||
|
||||
public override void OnKeyUp(KeyEventArgs keyEvent)
|
||||
{
|
||||
if (keyEvent.KeyCode == Keys.Enter
|
||||
|| keyEvent.KeyCode == Keys.Space)
|
||||
{
|
||||
UiThread.RunOnIdle(this.InvokeClick);
|
||||
}
|
||||
|
||||
base.OnKeyUp(keyEvent);
|
||||
}
|
||||
|
||||
public override Color BackgroundColor
|
||||
{
|
||||
get
|
||||
|
|
@ -104,6 +117,25 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
set => base.BackgroundColor = value;
|
||||
}
|
||||
|
||||
public override void OnFocusChanged(EventArgs e)
|
||||
{
|
||||
hasKeyboardFocus = this.Focused && !mouseInBounds;
|
||||
this.Invalidate();
|
||||
|
||||
base.OnFocusChanged(e);
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
base.OnDraw(graphics2D);
|
||||
|
||||
if (this.TabStop
|
||||
&& hasKeyboardFocus)
|
||||
{
|
||||
graphics2D.Rectangle(this.LocalBounds, theme.EditFieldColors.Focused.BorderColor);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Enabled
|
||||
{
|
||||
get => base.Enabled;
|
||||
|
|
@ -411,6 +443,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
this.Height = theme.ButtonHeight;
|
||||
this.Padding = theme.TextButtonPadding;
|
||||
this.TextColor = theme.TextColor;
|
||||
this.TabStop = true;
|
||||
|
||||
var textSize = (pointSize != -1) ? pointSize : theme.DefaultFontSize;
|
||||
|
||||
|
|
|
|||
|
|
@ -204,6 +204,9 @@ namespace MatterHackers.Agg.UI
|
|||
TopWindow = _openWindows.LastOrDefault();
|
||||
|
||||
platformWindow.ShowSystemWindow(TopWindow);
|
||||
|
||||
// Ensure focus is set to the new window
|
||||
systemWindow.Focus();
|
||||
}
|
||||
|
||||
public virtual void CloseSystemWindow(SystemWindow systemWindow)
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
serializationKey: "gcode_panel_details",
|
||||
expanded: true)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue