Skip to content

Commit

Permalink
fix(SquirrelPanel): text shown in top-left corner
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lotem committed Mar 15, 2024
1 parent baeb420 commit ff94b08
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions SquirrelPanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ff94b08

Please sign in to comment.