MouseRelease not running

MouseRelease not running

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
Freezerburn
Posts: 20
Joined: 26 Jan 2011, 20:25

MouseRelease not running

Post 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.
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: MouseRelease not running

Post by Niobium »

You need to return true on MousePress to get MouseMove/MouseRelease directed to your widget.
Freezerburn
Posts: 20
Joined: 26 Jan 2011, 20:25

Re: MouseRelease not running

Post by Freezerburn »

Aaaah, thank you. That should be mentioned in the wiki, methinks.
Post Reply

Return to “Lua Scripts”