Page 1 of 1

MouseRelease not running

Posted: 10 Apr 2011, 04:57
by Freezerburn
I have the following code:

Code: Select all

function widget:MousePress(x, y, button)
        echo("Mouse pressed")
	if button == 3 then
		CancelButton()
	end
end

function widget:MouseRelease(x, y, button)
	echo("Mouse released.")
	if button == 1 then
		echo("Left mouse button released at: " .. x .. ", " .. y)
		RegionAddGuiButton(x, y)
		RegionRemoveGuiButton(x, y)
		RegionMoveGuiButton(x, y)
	end
end
When I run Spring, I see the message telling me the mouse was pressed (and I have used that call-in for other logic as well and it has worked). However, I do not see the message saying that the mouse was released, period. I double and triple-checked the function name, and as far as I can tell it should be working (I even saw it in some other code). Why is this not working? I am incredibly confused about this.

Re: MouseRelease not running

Posted: 10 Apr 2011, 05:03
by Niobium
You need to return true on MousePress to get MouseMove/MouseRelease directed to your widget.

Re: MouseRelease not running

Posted: 10 Apr 2011, 05:41
by Freezerburn
Aaaah, thank you. That should be mentioned in the wiki, methinks.