Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can I implement mouse drag from one Studio plugin GUI to another?

Asked by
aschepler 135
6 years ago

I would like to be able to drag objects between two DockWidgetPluginGuis created by the same Studio plugin. I have dragging within a window working, but it seems I don't get any events for the other window while the mouse button is still held down.

Example code:

01local win1 = plugin:CreateDockWidgetPluginGui(
02    "MouseTest_Window1",
03    DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true)
04)
05win1.Name = "MouseTest_Window1"
06win1.Title = "Mouse Test 1"
07local frame1 = Instance.new("Frame", win1)
08frame1.Size = UDim2.new(1,0,1,0)
09frame1.BackgroundColor3 = Color3.new(.5, .5, .5)
10local square = Instance.new("Frame", frame1)
11square.Size = UDim2.new(0,50,0,50)
12square.BackgroundColor3 = Color3.new(.1, 1, .1)
13 
14local win2 = plugin:CreateDockWidgetPluginGui(
15    "MouseTest_Window2",
View all 71 lines...

The green square can be dragged around window 1, and fades if the mouse leaves that window, but I don't get any print output at all when the mouse moves into or through window 2. If I release the mouse button in window 2, I do start getting input events there, so I could "snap" the object into the window at that time, but it would be much nicer to be able to see where you're placing it.

I also tried looking at the plugin mouse from plugin:Activate(true) and plugin:GetMouse(), but didn't see any events from it during this sort of drag either.

Is there some way to detect a mouse drag into another window, or is this just not possible?

Answer this question