@@ -206,6 +206,17 @@ def webView_runJavaScriptConfirmPanelWithMessage_initiatedByFrame_completionHand
206
206
result = BrowserView .display_confirmation_dialog (ok , cancel , message )
207
207
handler (result )
208
208
209
+ # Display a Javascript input panel
210
+ def webView_runJavaScriptTextInputPanelWithPrompt_defaultText_initiatedByFrame_completionHandler_ (
211
+ self , webview , prompt , default_text , frame , handler
212
+ ):
213
+ i = BrowserView .get_instance ('webview' , webview )
214
+ ok = i .localization ['global.ok' ]
215
+ cancel = i .localization ['global.cancel' ]
216
+
217
+ result = BrowserView .display_input_dialog (ok , cancel , prompt , default_text )
218
+ handler (result )
219
+
209
220
# Display an open panel for <input type="file"> element
210
221
def webView_runOpenPanelWithParameters_initiatedByFrame_completionHandler_ (
211
222
self , webview , param , frame , handler
@@ -1132,6 +1143,27 @@ def display_confirmation_dialog(first_button, second_button, message):
1132
1143
1133
1144
return alert .runModal () == AppKit .NSAlertFirstButtonReturn
1134
1145
1146
+ @staticmethod
1147
+ def display_input_dialog (first_button , second_button , prompt , default_text ):
1148
+ AppKit .NSApplication .sharedApplication ()
1149
+ AppKit .NSRunningApplication .currentApplication ().activateWithOptions_ (
1150
+ AppKit .NSApplicationActivateIgnoringOtherApps
1151
+ )
1152
+ alert = AppKit .NSAlert .alloc ().init ()
1153
+ text_field = AppKit .NSTextField .alloc ().init ()
1154
+ text_field .setStringValue_ (default_text )
1155
+ text_field .sizeToFit ()
1156
+ alert .setAccessoryView_ (text_field )
1157
+ alert .addButtonWithTitle_ (first_button )
1158
+ alert .addButtonWithTitle_ (second_button )
1159
+ alert .setMessageText_ (prompt )
1160
+ alert .setAlertStyle_ (AppKit .NSWarningAlertStyle )
1161
+
1162
+ if alert .runModal () == AppKit .NSAlertFirstButtonReturn :
1163
+ return text_field .stringValue ()
1164
+ else :
1165
+ return None
1166
+
1135
1167
@staticmethod
1136
1168
def should_close (window ):
1137
1169
quit = window .localization ['global.quit' ]
0 commit comments