Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions plugin/src/AddAccountFlow/StartPage/BrowserFlow.luau
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local UserInputService = game:GetService("UserInputService")

local Plugin = script:FindFirstAncestor("StudioActivity")

local Packages = Plugin.Packages
Expand All @@ -6,6 +8,7 @@ local React = require(Packages.React)
local ReactCharm = require(Packages.ReactCharm)

local AuthContext = require(script.Parent.Parent.AuthContext)
local NotificationStore = require(Plugin.Source.Notification.NotificationStore)
local Steps = require(script.Parent.Steps)

local TextInput = Foundation.TextInput
Expand All @@ -18,6 +21,20 @@ local useState = React.useState
local useEffect = React.useEffect
local useCallback = React.useCallback

-- This is a horrible hack that allows us to copy the contents of a TextBox
-- to the clipboard, by sending a virtual ctrl + c keycode sequence.
--
-- Not sure if this will work long-term. Only one way to find out!
local function sendCopyKeycode()
local virtualInput: VirtualInput = UserInputService:CreateVirtualInput() :: any

virtualInput:SendKey(true, Enum.KeyCode.LeftControl)
virtualInput:SendKey(true, Enum.KeyCode.C)

virtualInput:SendKey(false, Enum.KeyCode.LeftControl)
virtualInput:SendKey(false, Enum.KeyCode.C)
end

local function BrowserFlow()
local auth = AuthContext.useAuth()

Expand Down Expand Up @@ -47,7 +64,16 @@ local function BrowserFlow()
if textbox then
textbox.TextEditable = false

local focusConnection = textbox.Focused:Connect(selectAll)
local focusConnection = textbox.Focused:Connect(function()
selectAll()

-- This hack might start to error in the future, so we wrap it
-- in a pcall just in case.
local success = pcall(sendCopyKeycode)
if success then
NotificationStore.get().push("info", "Copied URL to clipboard")
end
end)

-- Re-select all if the user clicks to move the cursor while focused.
-- CursorPosition changes when the user clicks within the box or
Expand Down Expand Up @@ -94,7 +120,7 @@ local function BrowserFlow()
steps = {
{
id = "step-1",
text = "Select and copy this link",
text = "Select to copy this link",
content = e(TextInput, {
onReturnPressed = function() end,
text = startUrl,
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/Notification/NotificationsContainer.luau
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local function NotificationsContainer()

return e(View, {
tag = "size-full",
ZIndex = 10,
ZIndex = 300,
}, active and e(Notification, {
key = tostring(active.id),
type = active.type,
Expand Down
2 changes: 1 addition & 1 deletion rokit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ wally = "UpliftGames/wally@0.3.2"
wally-package-types = "JohnnyMorganz/wally-package-types@1.6.2"
selene = "Kampfkarren/selene@0.30.1"
stylua = "johnnymorganz/stylua@2.4.0"
luau-lsp = "JohnnyMorganz/luau-lsp@1.66.0"
luau-lsp = "JohnnyMorganz/luau-lsp@1.67.0"
lune = "lune-org/lune@0.10.4"
roblox-packages = "flipbook-labs/roblox-packages@0.5.0"
lute = "luau-lang/lute@1.0.0"
Expand Down
Loading