Revision: 29490
          http://sourceforge.net/p/bibdesk/svn/29490
Author:   hofman
Date:     2025-08-28 16:48:00 +0000 (Thu, 28 Aug 2025)
Log Message:
-----------
run NSAlert with text field as accessory view as javascript text input panel

Modified Paths:
--------------
    trunk/bibdesk/BDSKTextImportController.m
    trunk/bibdesk/BDSKWebView.m

Modified: trunk/bibdesk/BDSKTextImportController.m
===================================================================
--- trunk/bibdesk/BDSKTextImportController.m    2025-08-28 14:52:13 UTC (rev 
29489)
+++ trunk/bibdesk/BDSKTextImportController.m    2025-08-28 16:48:00 UTC (rev 
29490)
@@ -1000,6 +1000,21 @@
     }];
 }
 
+- (void)webView:(WKWebView *)webView 
runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString 
*)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void 
(^)(NSString * result))completionHandler {
+    NSAlert *alert = [[NSAlert alloc] init];
+    [alert setMessageText:[self alertTitleForFrame:frame]];
+    [alert setInformativeText:prompt];
+    [alert addButtonWithTitle:NSLocalizedString(@"OK", @"Button title")];
+    [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"Button title")];
+    NSTextField *textField = [[NSTextField alloc] 
initWithFrame:NSMakeRect(0.0, 0.0, 300.0, 24.0)];
+    if (defaultText)
+        [textField setStringValue:defaultText];
+    [alert setAccessoryView:textField];
+    [alert beginSheetModalForWindow:[self window] 
completionHandler:^(NSModalResponse result){
+        completionHandler(result == NSAlertFirstButtonReturn ? [textField 
stringValue] : nil);
+    }];
+}
+
 - (WKWebView *)webView:(WKWebView *)aWebView 
createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration 
forNavigationAction:(WKNavigationAction *)navigationAction 
windowFeatures:(WKWindowFeatures *)windowFeatures {
     NSURL *url = [[navigationAction request] URL];
     

Modified: trunk/bibdesk/BDSKWebView.m
===================================================================
--- trunk/bibdesk/BDSKWebView.m 2025-08-28 14:52:13 UTC (rev 29489)
+++ trunk/bibdesk/BDSKWebView.m 2025-08-28 16:48:00 UTC (rev 29490)
@@ -676,6 +676,19 @@
     return NSAlertFirstButtonReturn == [alert runModal];
 }
 
+- (NSString *)webView:(WebView *)sender 
runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString 
*)defaultText initiatedByFrame:(WebFrame *)frame {
+    NSAlert *alert = [[NSAlert alloc] init];
+    [alert setMessageText:[self alertTitleForFrame:frame]];
+    [alert setInformativeText:prompt];
+    [alert addButtonWithTitle:NSLocalizedString(@"OK", @"Button title")];
+    [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"Button title")];
+    NSTextField *textField = [[NSTextField alloc] 
initWithFrame:NSMakeRect(0.0, 0.0, 300.0, 24.0)];
+    if (defaultText)
+        [textField setStringValue:defaultText];
+    [alert setAccessoryView:textField];
+    return NSAlertFirstButtonReturn == [alert runModal] ? [textField 
stringValue] : nil;
+}
+
 - (void)webView:(WebView *)sender 
runOpenPanelForFileButtonWithResultListener:(id < WebOpenPanelResultListener 
>)resultListener {
     NSOpenPanel *openPanel = [NSOpenPanel openPanel];
     if ([openPanel runModal] == NSModalResponseOK)

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



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to