public override void OnKeyPress(ICoreClientAPI api, KeyEvent args) { if (HasFocus) { string nowline = lines[caretPosLine].Substring(0, caretPosInLine) + args.KeyChar + lines[caretPosLine].Substring(caretPosInLine, lines[caretPosLine].Length - caretPosInLine); if (maxwidth > 0) { double nowWidth = Font.GetTextExtents(nowline).Width; if (nowWidth > maxwidth) { args.Handled = true; api.Gui.PlaySound("tick"); return; } } lines[caretPosLine] = nowline; TextChanged(); SetCaretPos(caretPosInLine + 1, caretPosLine); args.Handled = true; api.Gui.PlaySound("tick"); OnKeyPressed?.Invoke(); } }
public override void OnMouseUpOnElement(ICoreClientAPI api, MouseEvent args) { int mouseX = api.Input.MouseX; int mouseY = api.Input.MouseY; if (closeIconRect.PointInside(mouseX - Bounds.absX, mouseY - Bounds.absY)) { args.Handled = true; OnClose?.Invoke(); return; } if (menuIconRect.PointInside(mouseX - Bounds.absX, mouseY - Bounds.absY)) { listMenu.Open(); //listMenu.hoveredIndex = listMenu.selectedIndex = movable ? 1 : 0; return; } }
public override void OnFocusLost() { base.OnFocusLost(); OnLostFocus?.Invoke(); }
public override void OnFocusGained() { base.OnFocusGained(); SetCaretPos(TextLengthWithoutLineBreaks); OnFocused?.Invoke(); }