Methods
Method new()
Create a new RDesk application
Usage
App$new(title, width = 1200L, height = 800L, www = NULL, icon = NULL)
Arguments
title
Window title string
width
Window width in pixels (default 1200)
height
Window height in pixels (default 800)
www
Directory containing HTML/CSS/JS assets (default: built-in template)
icon
Path to window icon file
Returns
A new App instance
Method on_ready()
Register a callback to fire when the window is ready
Arguments
fn
A zero-argument function called after the server starts and window opens
Returns
The App instance (invisible)
Method on_close()
Register a callback to fire when the user attempts to close the window
Arguments
fn
A zero-argument function. Should return TRUE to allow closing, FALSE to cancel.
Returns
The App instance (invisible)
Method check_update()
Check for application updates from a remote URL
Usage
App$check_update(version_url, current_version = NULL)
Arguments
version_url
URL to a JSON metadata file (e.g. {"version": "1.1.0", "url": "http://..."})
current_version
Optional version string to compare against. Defaults to app description version.
Returns
A list with update status and metadata
Method register_hotkey()
Register a global keyboard shortcut (hotkey)
Usage
App$register_hotkey(keys, fn)
Arguments
keys
Character string representing the key combination (e.g., "Ctrl+Shift+A")
fn
A zero-argument function to be called when the hotkey is pressed
Returns
The App instance (invisible)
Set the native system tray menu
Arguments
items
A named list of lists defining the menu structure
Returns
The App instance (invisible)
Method clipboard_write()
Write text to the system clipboard
Usage
App$clipboard_write(text)
Arguments
text
Character string to copy
Returns
The App instance (invisible)
Method clipboard_read()
Read text from the system clipboard
Returns
Character string from clipboard or NULL
Method on_message()
Register a handler for a UI -> R message type
Arguments
type
Unique message identifier string
fn
A function(payload) called when this message type arrives
Returns
The App instance (invisible)
Method send()
Send a message from R to the UI
Usage
App$send(type, payload = list())
Arguments
type
Character string message type (received by rdesk.on() in JS)
payload
A list or data.frame to serialise as JSON payload
Returns
The App instance (invisible)
Method load_ui()
Load an HTML file into the window
Usage
App$load_ui(path = "index.html")
Arguments
path
Path relative to the www directory (e.g. "index.html")
Returns
The App instance (invisible)
Method set_size()
Set the window size dynamically
Usage
App$set_size(width, height)
Arguments
width
New width (pixels)
height
New height (pixels)
Returns
The App instance (invisible)
Method set_position()
Set the window position dynamically
Arguments
x
Horizontal position from left (pixels)
y
Vertical position from top (pixels)
Returns
The App instance (invisible)
Method set_title()
Set the window title dynamically
Returns
The App instance (invisible)
Method minimize()
Minimize the window to the taskbar
Returns
The App instance (invisible)
Method maximize()
Maximize the window to fill the screen
Returns
The App instance (invisible)
Method restore()
Restore the window from minimize/maximize
Returns
The App instance (invisible)
Method fullscreen()
Toggle fullscreen mode
Usage
App$fullscreen(enabled = TRUE)
Arguments
enabled
If TRUE, enters fullscreen. If FALSE, exits.
Returns
The App instance (invisible)
Method always_on_top()
Set the window to stay always on top of others
Usage
App$always_on_top(enabled = TRUE)
Arguments
enabled
If TRUE, always on top.
Returns
The App instance (invisible)
Set the native window menu
Arguments
items
A named list of lists defining the menu structure
Returns
The App instance (invisible)
Method dialog_open()
Open a native file-open dialog
Usage
App$dialog_open(title = "Open File", filters = NULL)
Arguments
title
Dialog title
filters
List of file filters, e.g. list("CSV files" = "*.csv")
Returns
Selected file path (character) or NULL if cancelled
Method dialog_save()
Open a native file-save dialog
Usage
App$dialog_save(title = "Save File", default_name = "", filters = NULL)
Arguments
title
Dialog title
default_name
Initial filename
filters
List of file filters
Returns
Selected file path (character) or NULL if cancelled
Method dialog_folder()
Open a native folder selection dialog
Usage
App$dialog_folder(title = "Select Folder")
Returns
Selected directory path (character) or NULL if cancelled
Method message_box()
Show a native message box / alert
Usage
App$message_box(message, title = "RDesk", type = "ok", icon = "info")
Arguments
message
The message text
title
The dialog title
type
One of "ok", "okcancel", "yesno", "yesnocancel"
icon
One of "info", "warning", "error", "question"
Returns
The button pressed (character: "ok", "cancel", "yes", "no")
Method dialog_color()
Open a native color selection dialog
Usage
App$dialog_color(initial_color = "#FFFFFF")
Arguments
initial_color
Optional hex color to start with (e.g. "#FF0000")
Returns
Selected hex color code or NULL if cancelled
Method notify()
Send a native desktop notification
Usage
App$notify(title, body = "")
Arguments
title
Notification title
body
Notification body text
Returns
The App instance (invisible)
Method loading_start()
Show a loading state in the UI
Usage
App$loading_start(
message = "Loading...",
progress = NULL,
cancellable = FALSE,
job_id = NULL
)
Arguments
message
Text shown under the spinner
progress
Optional numeric 0-100 for a progress bar
cancellable
If TRUE, shows a cancel button in the UI
job_id
Optional job_id from rdesk_async() to wire cancel button
Method loading_progress()
Update progress on an active loading state
Usage
App$loading_progress(value, message = NULL)
Arguments
value
Numeric 0-100
message
Optional updated message
Method loading_done()
Hide the loading state in the UI
Method toast()
Show a non-blocking toast notification in the UI
Usage
App$toast(message, type = "info", duration_ms = 3000L)
Arguments
message
Text to show
type
One of "info", "success", "warning", "error"
duration_ms
How long to show it (default 3000ms)
Method set_tray()
Set or update the system tray icon
Usage
App$set_tray(label = "RDesk App", icon = NULL, on_click = NULL)
Arguments
label
Tooltip text for the tray icon
icon
Path to .ico file (optional)
on_click
Character "left" or "right" or callback function(button)
Returns
The App instance (invisible)
Method remove_tray()
Remove the system tray icon
Returns
The App instance (invisible)
Method service()
Service this app's pending native events
Returns
The App instance (invisible)
Close the window and stop the app's event loop.
Returns
The App instance (invisible)
Method get_dir()
Get the application root directory (where www/ and R/ are located).
Returns
Character string path.
Method run()
Start the application - opens the window
Arguments
block
If TRUE (default), blocks with an event loop until the window is closed.
Method clone()
The objects of this class are cloneable with this method.
Arguments
deep
Whether to make a deep clone.