Files
plainleaf/libraries/Library/Std/Editor/Read Only Mode.md
T
Zef Hemel f6308c788c Adds back "lock" button on mobile
This can be used to toggle between read-only mode, useful for mobile
users that are primarily navigating, not editing
2026-03-13 09:14:52 +01:00

718 B

#meta

Adds commands and an action button (on mobile) for toggling read-only mode.

function toggleReadOnlyMode()
  local ro = editor.getUiOption("forcedROMode")
  ro = not ro
  editor.setUiOption("forcedROMode", ro)
  editor.rebuildEditorState()
  if ro then
    editor.flashNotification("Read-only mode enabled")
  else
    editor.flashNotification("Read-only mode disabled")
  end
end

print("System mode", system.getMode())

if system.getMode() == "rw" then
  command.define {
    name = "Editor: Toggle Read Only Mode",
    run = toggleReadOnlyMode
  }

  actionButton.define {
    icon = "lock",
    description = "Toggle read-only mode",
    mobile = true,
    run = toggleReadOnlyMode
  }
end