Hello, I’m trying to make my plugin. Sadly, DockPluginWidgetGui don’t work with UserInput and ContextAction services. So I thinked about PluginActions. But IDK how to bind certein shortcuts to them, like Ctrl+A, or LMB+Shift
So, can someonne tell me, is it possible or nope?
For plugin contexts, you can use UserInputService but it only works with the workspace viewport.
If you want to have an action set while the plugin is focused, you can use listeners on a UI element for the InputBegan/Ended events. (This won’t be able to detect an input if the user has a different window focused such as the explorer, ribbon bar, output, etc.) If you need a shift+mouse click for a button in your plugin window, this is the best method.
Click to view a plugin that will gather the current input.
local newWidgetInfo = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float, -- Widget will be initialized in floating panel
true, -- Widget will be initially enabled
false, -- Override the previous enabled state?
500, -- Default width of the floating window
500, -- Default height of the floating window
500, -- Minimum width of the floating window (optional)
500 -- Minimum height of the floating window (optional)
)
local TestingUI = plugin:CreateDockWidgetPluginGui("Testing Inputs", newWidgetInfo)
local TextBox = Instance.new("TextLabel", TestingUI)
TextBox.TextScaled = true
TextBox.Size = UDim2.new(1,0,1,0)
TextBox.Text = ""
local HeldKeys = {}
local FilteredInputs = {Enum.UserInputType.MouseMovement, Enum.UserInputType.Focus}
function InputBegan(Input)
if Input.KeyCode ~= Enum.KeyCode.Unknown then
Input = Input.KeyCode
else
Input = Input.UserInputType
end
if not table.find(FilteredInputs, Input) then
if not table.find(HeldKeys, Input.Name) then
table.insert(HeldKeys, Input.Name)
end
end
end
function InputEnded(Input)
if Input.KeyCode ~= Enum.KeyCode.Unknown then
Input = Input.KeyCode
else
Input = Input.UserInputType
end
if not table.find(FilteredInputs, Input) then
if table.find(HeldKeys, Input.Name) then
table.remove(HeldKeys, table.find(HeldKeys, Input.Name))
end
end
end
TextBox.InputBegan:Connect(InputBegan)
TextBox.InputEnded:Connect(InputEnded)
game.UserInputService.InputBegan:Connect(InputBegan)
game.UserInputService.InputEnded:Connect(InputEnded)
while task.wait(1/30) do
TextBox.Text = table.concat(HeldKeys,"+")
end
You can use PluginActions for keybinds without needing your plugin focused but the end-users needs to set the keybind themselves (keybinds are empty by default and cannot be set by the plugin). You can only react to when the keybind is pressed and you won’t be able to check what the binding is. Also, key bindings don’t support mouse clicks for obvious reasons.
It really depends on what you’re trying to accomplish.
Hello, thx for your so good answer on my question.
But I have 1 question more: is Button.InputBegan/Ended can detect MouseButton3 clicks/up/down events?
I just can’t rn open studio sadly.
Yes it can.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.