protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
if (!e.Handled) {
// Should we add text to _focusShape or create a new text shape?
bool ignorePanel = false;
if (_focusShape != null && _focusShape.IsPanel && string.IsNullOrEmpty(_focusShape.PlainText()))
ignorePanel = true;
if (_focusShape != null && !ignorePanel) {
_focusShape.OnKeyPress(e);
} else if (e.KeyChar >= 32 && _lastClickLocation != null) {
var pt = _lastClickLocation.Value;
int w = (Width / 4).PutInRange(100, 400);
int h = (Height / 8).PutInRange(50, 200);
var newShape = new TextBox(new BoundingBox<float>(pt.X - w / 2, pt.Y, pt.X + w / 2, pt.Y + h)) {
Text = e.KeyChar.ToString(),
BoxType = BoxType.Borderless,
TextJustify = LLTextShape.JustifyUpperCenter,
Style = BoxStyle
};
AddShape(newShape);
}
}
}