|
From: <ho...@us...> - 2025-07-11 09:32:20
|
Revision: 15637
http://sourceforge.net/p/skim-app/code/15637
Author: hofman
Date: 2025-07-11 09:32:17 +0000 (Fri, 11 Jul 2025)
Log Message:
-----------
use separate mehods to start editing text note and updating its layout
Modified Paths:
--------------
trunk/SKPDFView.m
trunk/SKTextNoteEditor.h
trunk/SKTextNoteEditor.m
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2025-07-11 09:16:30 UTC (rev 15636)
+++ trunk/SKPDFView.m 2025-07-11 09:32:17 UTC (rev 15637)
@@ -413,7 +413,7 @@
- (void)layoutDocumentView {
[super layoutDocumentView];
[self resetPDFToolTipRects];
- [editor layoutWithEvent:nil];
+ [editor layout];
}
#pragma mark Drawing
@@ -2771,7 +2771,7 @@
editor = [[SKTextNoteEditor alloc] initWithPDFView:self annotation:currentAnnotation];
[[self window] makeFirstResponder:self];
- [editor layoutWithEvent:theEvent];
+ [editor startEditingWithEvent:theEvent];
[self updatedAnnotation:currentAnnotation];
}
@@ -3147,7 +3147,7 @@
if ([annotation isNote])
[self resetPDFToolTipRects];
if ([self isEditingAnnotation:annotation])
- [editor layoutWithEvent:nil];
+ [editor layout];
}
- (void)registerForDocumentNotifications {
@@ -3185,7 +3185,7 @@
- (void)handleScaleChangedNotification:(NSNotification *)notification {
[self resetPDFToolTipRects];
[self updatePacer];
- [editor layoutWithEvent:nil];
+ [editor layout];
}
- (void)handleUpdateTrackingAreasNotification:(NSNotification *)notification {
Modified: trunk/SKTextNoteEditor.h
===================================================================
--- trunk/SKTextNoteEditor.h 2025-07-11 09:16:30 UTC (rev 15636)
+++ trunk/SKTextNoteEditor.h 2025-07-11 09:32:17 UTC (rev 15637)
@@ -52,7 +52,8 @@
@property (nonatomic, nullable, weak, readonly) NSString *currentString;
-- (void)layoutWithEvent:(nullable NSEvent *)event;
+- (void)startEditingWithEvent:(nullable NSEvent *)event;
+- (void)updateLayout;
- (void)discardEditing;
- (BOOL)commitEditing;
Modified: trunk/SKTextNoteEditor.m
===================================================================
--- trunk/SKTextNoteEditor.m 2025-07-11 09:16:30 UTC (rev 15636)
+++ trunk/SKTextNoteEditor.m 2025-07-11 09:32:17 UTC (rev 15637)
@@ -39,7 +39,6 @@
#import "SKTextNoteEditor.h"
#import "PDFView_SKExtensions.h"
#import "PDFAnnotation_SKExtensions.h"
-#import "PDFPage_SKExtensions.h"
#import "NSView_SKExtensions.h"
#import "NSEvent_SKExtensions.h"
#import "SKChainedUndoManager.h"
@@ -90,7 +89,7 @@
return [textView string] ?: [annotation string];
}
-- (void)updateFrame:(NSNotification *)note {
+- (void)updateFrame {
NSRect frame = [pdfView backingAlignedRect:[pdfView convertRect:[annotation bounds] fromPage:[annotation page]] options:NSAlignAllEdgesNearest];
frame = [pdfView convertRect:frame toView:[pdfView documentView]];
[self setFrame:frame];
@@ -146,8 +145,6 @@
[self addSubview:clipView];
[self updateParagraphStyle];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateFrame:) name:SKPDFPageBoundsDidChangeNotification object:[pdfView document]];
}
- (void)endEditingWithCommit:(BOOL)commit {
@@ -182,29 +179,30 @@
[thePdfView textNoteEditorDidEndEditing:self];
}
-- (void)layoutWithEvent:(NSEvent *)event {
- if ([pdfView isPageAtIndexDisplayed:[annotation pageIndex]]) {
- [self setUpTextView];
- [self updateFrame:nil];
- if ([self superview] == nil) {
- [[pdfView documentView] addSubview:self];
- [[pdfView window] recalculateKeyViewLoop];
- [textView scrollPoint:NSZeroPoint];
- if (event) {
- [[textView window] makeFirstResponder:textView];
- [textView mouseDown:event];
- } else if ([[[pdfView window] firstResponder] isEqual:pdfView]) {
- NSRange range = NSMakeRange(0, [[textView string] length]);
- [textView setSelectedRange:range];
- [[textView window] makeFirstResponder:textView];
- }
- [annotation setShouldDisplay:NO];
- }
+- (void)startEditingWithEvent:(NSEvent *)event {
+ [self setUpTextView];
+ [self updateFrame];
+ [[pdfView documentView] addSubview:self];
+ [[pdfView window] recalculateKeyViewLoop];
+ [textView scrollPoint:NSZeroPoint];
+ [annotation setShouldDisplay:NO];
+ if (event) {
+ [[textView window] makeFirstResponder:textView];
+ [textView mouseDown:event];
} else {
- [self endEditingWithCommit:YES];
+ NSRange range = NSMakeRange(0, [[textView string] length]);
+ [textView setSelectedRange:range];
+ [[textView window] makeFirstResponder:textView];
}
}
+- (void)updateLayout {
+ if ([pdfView isPageAtIndexDisplayed:[annotation pageIndex]])
+ [self updateFrame];
+ else
+ [self endEditingWithCommit:YES];
+}
+
- (void)discardEditing {
[self endEditingWithCommit:NO];
}
@@ -243,7 +241,7 @@
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (context == &SKPDFAnnotationPropertiesObservationContext) {
if ([keyPath isEqualToString:SKNPDFAnnotationBoundsKey]) {
- [self updateFrame:nil];
+ [self updateFrame];
} else if ([keyPath isEqualToString:SKNPDFAnnotationFontKey]) {
[textView setFont:[annotation font]];
[self updateParagraphStyle];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|