From c58a5b520ed933ca900b3d0f24e288a269defa45 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Fri, 29 May 2026 18:19:03 +0200 Subject: [PATCH] fixed: tab copypaste --- AppKit/CPTextView/CPParagraphStyle.j | 8 ++++++-- AppKit/CPTextView/CPTextView.j | 3 ++- Tests/Manual/CPTextView/AppController.j | 9 +-------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/AppKit/CPTextView/CPParagraphStyle.j b/AppKit/CPTextView/CPParagraphStyle.j index 2e2f3f6b9..8f7176550 100644 --- a/AppKit/CPTextView/CPParagraphStyle.j +++ b/AppKit/CPTextView/CPParagraphStyle.j @@ -56,6 +56,12 @@ var kDefaultTabInterval = 28.0; return [self initWithTextAlignment:aType location:aLocation options:nil]; } +// Added to resolve the unrecognized selector exception in the RTF producer +- (CPTabStopType)tabStopType +{ + return _alignment; +} + - (BOOL)isEqual:(id)other { if (self === other) return YES; @@ -217,8 +223,6 @@ var _sharedDefaultParagraphStyle = nil; @end -// MARK: - CPMutableParagraphStyle Implementation - // MARK: - CPMutableParagraphStyle Implementation @implementation CPMutableParagraphStyle : CPParagraphStyle diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 916549d58..21ffa7bc3 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -3049,8 +3049,9 @@ var _CPCopyPlaceholder = '-'; // Intercept problematic keys before the browser acts. _CPNativeInputField.addEventListener('keydown', function(e) { - if (e.key === 'Enter' || (e.key === 'Backspace' && _CPNativeInputField.innerHTML === '')) { + if (e.key === 'Tab' || e.key === 'Enter' || (e.key === 'Backspace' && _CPNativeInputField.innerHTML === '')) { // Prevent browser default action: + // - 'Tab': Prevents browser focus navigation, allowing Cappuccino key bindings (like option-tab or tab) to work. // - 'Enter': Prevents inserting

. // - 'Backspace' on empty: Prevents inserting junk characters on iPadOS. e.preventDefault(); diff --git a/Tests/Manual/CPTextView/AppController.j b/Tests/Manual/CPTextView/AppController.j index 128eb6c23..7abb6d277 100755 --- a/Tests/Manual/CPTextView/AppController.j +++ b/Tests/Manual/CPTextView/AppController.j @@ -287,7 +287,7 @@ var elegantForeground = [CPColor colorWithRed:0.18 green:0.24 blue:0.35 alpha:1.0]; // Slate Blue var elegantBackground = [CPColor colorWithRed:0.92 green:0.95 blue:0.98 alpha:1.0]; // Soft Sky Blue tint - [_textView insertText:[[CPAttributedString alloc] initWithString:@"Fusce\n" + [_textView insertText:[[CPAttributedString alloc] initWithString:@"My Headline with blue background\n" attributes:[CPDictionary dictionaryWithObjects:[centeredParagraph, [CPFont boldFontWithName:@"Arial" size:18], elegantForeground, elegantBackground] forKeys:[CPParagraphStyleAttributeName, CPFontAttributeName, CPForegroundColorAttributeName, CPBackgroundColorAttributeName]]]]; @@ -323,13 +323,6 @@ [theWindow orderFront:self]; [CPMenu setMenuBarVisible:YES]; - - console.log([[CPFont systemFontOfSize:12] cssString]) - var context = document.createElement("canvas").getContext("2d"); - context.font = '12px Arial, sans-serif'; - var testingText = 'A A A A A A A A'; - console.log(ROUND(context.measureText(testingText).width)); - console.log(ROUND([CPPlatformString sizeOfString:testingText withFont:[CPFont systemFontOfSize:12] forWidth:NULL].width)); } - (void)makeRTF:(id)sender