Documentation
¶
Overview ¶
Package native provides native system functions for Linux, MacOS and Windows to perform operating system-specific tasks such as open web links or native dialog boxes.
Index ¶
- Variables
- func CopyToClipboard(text string) error
- func CountTextures(e render.Engine) string
- func FreeTextures(e render.Engine)
- func IsTouchScreenMode() bool
- func MaximizeWindow(e render.Engine)
- func OpenFile(title string, filter string) (string, error)
- func OpenLocalURL(path string)
- func OpenURL(url string)
- func SaveFile(title string, filter string) (string, error)
- func TextToImage(e render.Engine, text render.Text) (image.Image, error)
- func UpdateTouchScreenMode(ev *event.State)
Constants ¶
This section is empty.
Variables ¶
var ( USER string = os.Getenv("USER") DefaultAuthor = USER )
var ( // This is set to True when a file dialog driver is available. // If false, a fallback uses the developer shell Prompt() // to ask for a file name. FileDialogsReady bool )
FileDialog common variables.
var ( // Force the TouchScreenMode to always be enabled. ForceTouchScreenModeAlwaysOn bool )
Functions ¶
func CopyToClipboard ¶
CopyToClipboard puts some text on your clipboard.
func CountTextures ¶
CountTextures returns the count of loaded SDL2 textures, for the F3 debug overlay, or "n/a"
func FreeTextures ¶
FreeTextures will free all SDL2 textures currently in memory.
func IsTouchScreenMode ¶
func IsTouchScreenMode() bool
IsTouchScreenMode is activated when the user has touched the screen, and false when the mouse is moved.
func OpenFile ¶
OpenFile invokes a native File Chooser dialog with the title and a set of file filters. The filters are a sequence of label and comma-separated file extensions.
Example: OpenFile("Pick a file", "Images", "png,gif,jpg", "Audio", "mp3")
func OpenLocalURL ¶
func OpenLocalURL(path string)
OpenLocalURL opens a web browser to a local HTML path. It converts a relative path like "guidebook/index.html" to its absolute filesystem location.
func OpenURL ¶
func OpenURL(url string)
OpenURL opens a web browser to the given URL.
On Linux this will look for xdg-open or try a few common browser names. On Windows this uses the “start“ command. On MacOS this uses the “open“ command.
func SaveFile ¶
SaveFile invokes a native File Chooser dialog with the title and a set of file filters. The filters are a sequence of label and comma-separated file extensions.
Example: SaveFile("Pick a file", "Images", "png,gif,jpg", "Audio", "mp3")
func TextToImage ¶
TextToImage takes an SDL2_TTF texture and makes it into a Go image.
Notes: - The text is made Black & White with a white background on the image. - Drop shadow, stroke, etc. probably not supported. - Returns a non-antialiased image.
func UpdateTouchScreenMode ¶
UpdateTouchScreenMode evaluates whether the primary game input is a touch screen rather than a mouse cursor.
The game always hides the OS cursor (if it exists) and may draw its own custom mouse cursor.
On a touch screen device (such as a mobile), the custom mouse cursor should not be drawn, either, as it would jump around to wherever the user last touched and be distracting.
TouchScreenMode is activated when a touch event has been triggered (at least one finger was down).
TouchScreenMode deactivates and shows the mouse cursor when no finger is held down, and then a mouse event has occurred. So if the user has a touch screen laptop, wiggling the actual mouse input will bring the cursor back.
Types ¶
This section is empty.