Revision: 14014
          http://sourceforge.net/p/skim-app/code/14014
Author:   hofman
Date:     2024-01-16 17:39:48 +0000 (Tue, 16 Jan 2024)
Log Message:
-----------
Use NSSearchToolbarItem for search field when available

Modified Paths:
--------------
    trunk/SKNotesDocument.m

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2024-01-14 23:06:16 UTC (rev 14013)
+++ trunk/SKNotesDocument.m     2024-01-16 17:39:48 UTC (rev 14014)
@@ -99,6 +99,16 @@
 #define EXTRA_ROW_HEIGHT 2.0
 #define DEFAULT_TEXT_ROW_HEIGHT 85.0
 
+#if SDK_BEFORE_11_0
+@interface NSSearchToolbarItem : NSToolbarItem
+@property (strong) NSSearchField *searchField;
+@property BOOL resignsFirstResponderWithCancel;
+@property CGFloat preferredWidthForSearchField;
+- (void)beginSearchInteraction;
+- (void)endSearchInteraction;
+@end
+#endif
+
 @implementation SKNotesDocument
 
 @synthesize outlineView, statusBar, arrayController, searchField, notes, 
pdfDocument, sourceFileURL;
@@ -885,16 +895,25 @@
     
     // Add template toolbar items
     
-    item = [[SKToolbarItem alloc] 
initWithItemIdentifier:SKNotesDocumentSearchToolbarItemIdentifier];
-    [item setLabels:NSLocalizedString(@"Search", @"Toolbar item label")];
-    [item setToolTip:NSLocalizedString(@"Search Notes", @"Tool tip message")];
-    [item setView:searchField];
-    if (@available(macOS 11.0, *)) {} else {
+    if (@available(macOS 11.0, *)) {
+#if SDK_BEFORE_11_0
+        NSSearchToolbarItem *searchItem = 
[[NSClassFromString(@"NSSearchToolbarItem") alloc] 
initWithItemIdentifier:SKNotesDocumentSearchToolbarItemIdentifier];
+#else
+        NSSearchToolbarItem *searchItem = [[NSSearchToolbarItem alloc] 
initWithItemIdentifier:SKNotesDocumentSearchToolbarItemIdentifier];
+#endif
+        [searchItem setSearchField:searchField];
+        [searchItem setPreferredWidthForSearchField:300.0];
+        item = searchItem;
+    } else {
+        item = [[SKToolbarItem alloc] 
initWithItemIdentifier:SKNotesDocumentSearchToolbarItemIdentifier];
+        [item setView:searchField];
         NSSize size = [searchField frame].size;
         [item setMinSize:size];
         size.width = 240.0;
         [item setMaxSize:size];
     }
+    [item setLabels:NSLocalizedString(@"Search", @"Toolbar item label")];
+    [item setToolTip:NSLocalizedString(@"Search Notes", @"Tool tip message")];
     [dict setObject:item forKey:SKNotesDocumentSearchToolbarItemIdentifier];
     
     item = [[SKToolbarItem alloc] 
initWithItemIdentifier:SKNotesDocumentOpenPDFToolbarItemIdentifier];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to