requesters.monkey2 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. Namespace std.requesters
  2. #If __TARGET__="windows"
  3. #Import "<libole32.a>"
  4. #Import "<libComdlg32.a>"
  5. #Import "native/requesters_windows.cpp"
  6. #Import "native/requesters.h"
  7. #Elseif __TARGET__="macos"
  8. #Import "native/requesters_macos.mm"
  9. #Import "native/requesters.h"
  10. #Elseif __TARGET__="linux"
  11. #Import "native/requesters_linux.cpp"
  12. #Import "native/requesters.h"
  13. #Elseif __TARGET__="android"
  14. #Import "<sdl2>"
  15. #Import "<jni>"
  16. #Import "native/Monkey2Requesters.java"
  17. #Elseif __TARGET__="ios"
  18. #Import "native/requesters_ios.mm"
  19. #Import "native/requesters.h"
  20. #Endif
  21. #If __DESKTOP_TARGET__
  22. Extern
  23. #rem monkeydoc Activates a modal notification dialog.
  24. Notify activates a simple modal dialog informing the user of an event. The optional `serious` flag can be used to indicate a 'critical' event.
  25. #end
  26. Function Notify:Void( title:String,text:String,serious:Bool=False )="bbRequesters::Notify"
  27. #rem monkeydoc Activates a simple modal Yes/No dialog.
  28. Confirm activates a simple modal dialog requesting the user to select between Yes and No options. If the user selects Yes, then Confirm returns true. Otherwise, false is returned.
  29. #end
  30. Function Confirm:Bool( title:String,text:String,serious:Bool=False )="bbRequesters::Confirm"
  31. #rem monkeydoc Activates a modal Yes/No/Cancel dialog.
  32. Proceed activates a simple modal dialog requesting the user to select between Yes, No and Cancel options. If the user selects Yes, then Proceed return 1. If the user selects No, then Proceed returns 0. Otherwise, Proceed returns -1.
  33. #end
  34. Function Proceed:Int( title:String,text:String,serious:Bool=False )="bbRequesters::Proceed"
  35. #rem monkeydoc Activate a modal file requester dialog.
  36. RequestFile activates a modal file requester dialog.
  37. The optional filters string can either be a comma separated list of file extensions or, as in the following example, groups of extensions that begin with a "group:" label and are separated by a semicolon. For example:
  38. "Image files:png,jpg;Audio files:was,ogg;All files:*"
  39. The save parameter should be true to create a save-style requester, false to create a load-style requester.
  40. The `path` parameter can be used to specify an initial file path.
  41. Returns selected file path, or an empty string if dialog was cancelled.
  42. #end
  43. Function RequestFile:String( title:String,filter:String="",save:Bool=False,file:String="" )="bbRequesters::RequestFile"
  44. #rem monkeydoc Activates a modal directory path dialog.
  45. RequestDir activates a modal directory path dialog.
  46. The `dir` parameter can be used to specify an initial directory path.
  47. Returns selected directory path, or an empty string if dialog was cancelled.
  48. #end
  49. Function RequestDir:String( title:String,dir:String="" )="bbRequesters::RequestDir"
  50. #rem monkeydoc Opens a URL using the desktop manager.
  51. Opens a URL using the desktop manager.
  52. The behavior of OpenURL is highly target dependent, but in general it should at least be able to open web pages for you!
  53. #end
  54. Function OpenUrl( url:String )="bbRequesters::OpenUrl"
  55. Public
  56. #Elseif __TARGET__="android"
  57. Function OpenUrl( url:String )
  58. Local env:=sdl2.Android_JNI_GetEnv()
  59. Local cls:=env.FindClass( "com/monkey2/lib/Monkey2Requesters" )
  60. Local mth:=env.GetStaticMethodID( cls,"openUrl","(Ljava/lang/String;)V" )
  61. env.CallStaticVoidMethod( cls,mth,New Variant[]( url ) )
  62. End
  63. #Elseif __TARGET__="ios"
  64. Extern
  65. Function OpenUrl( url:String )="bbRequesters::OpenUrl"
  66. Public
  67. #Endif