Page 2 of 2
Re: mouseMoveCaptured with right mouse button - bug?
Posted: Sun Nov 16, 2014 11:47 am
by tulamide
billv wrote:Code: Select all
def mouseLDown x,y
@mouse=0
captureMouse if @mouse = 0
end
def mouseRDown x,y
@mouse=1
captureMouse if @mouse = 1
end
def mouseMoveCaptured x,y
if @mouse==0 then
output 0,x
elsif @mouse==1 then
output 1,y
end
end
def mouseLUp x,y
releaseMouse if @mouse = 0
end
def mouseRUp x,y
releaseMouse if @mouse = 1
end
Don't quite get this. The 'if' statement doesn't check for a value but assigns either 0 or 1 (e.g. @mouse = 1, instead of @mouse == 1). But then you don't need an 'if'. The code line before would be sufficient.
Re: mouseMoveCaptured with right mouse button - bug?
Posted: Sun Nov 16, 2014 12:06 pm
by billv
billv wrote:(e.g. @mouse = 1, instead of @mouse == 1)
yeh...that' parts not needed it seems...and wrong anyway...
Still works fine without it. Thanks..
Re: mouseMoveCaptured with right mouse button - bug?
Posted: Sun Nov 16, 2014 12:22 pm
by tulamide
billv wrote:yeh...I'm not sure why @mouse = 1 works here...still has me thinking a bit.....
That's because "if var = value" isn't an error of any kind. In ruby, var will be assigned the value and then checked if it's true, which is is of course ("var = value" will always be true). It doesn't harm in this case, since you intended to set the var to the value, but
is sufficient. And the last two should work with a double equal. Unless there's a severe issue with Ruby in Flowstone...
EDIT: Just saw your edited answer. Wrote this before, so I'll leave it, for others to read^^
Re: mouseMoveCaptured with right mouse button - bug?
Posted: Sun Nov 16, 2014 12:58 pm
by billv
Thanks tulamide
I"m finding the release part is no good as well.....
So I've ended up with this...
Code: Select all
def mouseLDown x,y
@mouse=0
captureMouse
end
def mouseRDown x,y
@mouse=1
captureMouse
end
def mouseMoveCaptured x,y
if @mouse==0 then
output 0,x
elsif @mouse==1 then
output 1,y
end
end
def mouseLUp x,y
releaseMouse
@mouse = 0
end
def mouseRUp x,y
releaseMouse
@mouse = 1
end