actions.gd 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. extends Node
  2. func _on_OpenShellWeb_pressed():
  3. OS.shell_open("https://example.com")
  4. func _on_OpenShellFolder_pressed():
  5. var path = OS.get_environment("HOME")
  6. if path == "":
  7. # Windows-specific.
  8. path = OS.get_environment("USERPROFILE")
  9. OS.shell_open(path)
  10. func _on_ChangeWindowTitle_pressed():
  11. OS.set_window_title("Modified window title. Unicode characters for testing: é € × Ù ¨")
  12. func _on_ChangeWindowIcon_pressed():
  13. var image = preload("res://icon.png").get_data()
  14. # Use an operation that will cause the icon to change in a visible manner.
  15. image.bumpmap_to_normalmap()
  16. OS.set_icon(image)
  17. func _on_MoveWindowToForeground_pressed():
  18. OS.set_window_title("Will move window to foreground in 5 seconds, try unfocusing the window...")
  19. yield(get_tree().create_timer(5), "timeout")
  20. OS.move_window_to_foreground()
  21. # Restore the previous window title.
  22. OS.set_window_title(ProjectSettings.get_setting("application/config/name"))
  23. func _on_RequestAttention_pressed():
  24. OS.set_window_title("Will request attention in 5 seconds, try unfocusing the window...")
  25. yield(get_tree().create_timer(5), "timeout")
  26. OS.request_attention()
  27. # Restore the previous window title.
  28. OS.set_window_title(ProjectSettings.get_setting("application/config/name"))
  29. func _on_VibrateDeviceShort_pressed():
  30. Input.vibrate_handheld(200)
  31. func _on_VibrateDeviceLong_pressed():
  32. Input.vibrate_handheld(1000)
  33. func _on_AddGlobalMenuItems_pressed():
  34. OS.global_menu_add_item("Hello", "World", 0, null)
  35. OS.global_menu_add_separator("Hello")
  36. OS.global_menu_add_item("Hello2", "World2", 0, null)
  37. func _on_RemoveGlobalMenuItem_pressed():
  38. OS.global_menu_remove_item("Hello", 0)
  39. func _on_GetClipboard_pressed():
  40. OS.alert("Clipboard contents:\n\n%s" % OS.clipboard)
  41. func _on_SetClipboard_pressed():
  42. OS.clipboard = "Modified clipboard contents. Unicode characters for testing: é € × Ù ¨"
  43. func _on_DisplayAlert_pressed():
  44. OS.alert("Hello from Godot! Close this dialog to resume the main window.")
  45. func _on_KillCurrentProcess_pressed():
  46. OS.kill(OS.get_process_id())