From 277ebfa4c3efa8afaac61e4e8036842369ff960e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=85=E6=88=8E=E6=B0=8F?= Date: Fri, 15 Mar 2024 22:52:49 +0800 Subject: [PATCH] fix(SquirrelPanel): text shown in top-left corner (#856) it happens when the panel is displayed for the first time. usually it's the ascii mode status tooltip. calling setTextContainerInset: in drawRect: has no effect for what's being drawn. fixed by setting the inset on an ealier occasion. --- SquirrelPanel.m | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/SquirrelPanel.m b/SquirrelPanel.m index a7ec23945..37f056797 100644 --- a/SquirrelPanel.m +++ b/SquirrelPanel.m @@ -829,10 +829,6 @@ - (void)drawRect:(NSRect)dirtyRect { CGPathRef preeditPath = CGPathCreateMutable(); SquirrelTheme* theme = self.currentTheme; - NSPoint textFieldOrigin = dirtyRect.origin; - textFieldOrigin.y += theme.edgeInset.height; - textFieldOrigin.x += theme.edgeInset.width; - // Draw preedit Rect NSRect backgroundRect = dirtyRect; NSRect containingRect = dirtyRect; @@ -1030,8 +1026,6 @@ - (void)drawRect:(NSRect)dirtyRect { } [panelLayer addSublayer:layer]; } - [_textView - setTextContainerInset:NSMakeSize(textFieldOrigin.x, textFieldOrigin.y)]; } - (BOOL)clickAtPoint:(NSPoint)_point index:(NSInteger*)_index { @@ -1465,9 +1459,12 @@ - (void)show { [self.contentView setBoundsOrigin:NSMakePoint(0, 0)]; [_view.textView setBoundsOrigin:NSMakePoint(0, 0)]; } - BOOL translucency = theme.translucency; [_view setFrame:self.contentView.bounds]; [_view.textView setFrame:self.contentView.bounds]; + [_view.textView setTextContainerInset:NSMakeSize(theme.edgeInset.width, + theme.edgeInset.height)]; + + BOOL translucency = theme.translucency; if (translucency) { [_back setFrame:self.contentView.bounds]; _back.appearance = NSApp.effectiveAppearance;