mouseMoveCaptured with right mouse button - bug?

For general discussion related FlowStone
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: mouseMoveCaptured with right mouse button - bug?

Post 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.
"There lies the dog buried" (German saying translated literally)
billv
Posts: 1165
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia
Contact:

Re: mouseMoveCaptured with right mouse button - bug?

Post 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..
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: mouseMoveCaptured with right mouse button - bug?

Post 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

Code: Select all

@mouse = 0
captureMouse


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^^
"There lies the dog buried" (German saying translated literally)
billv
Posts: 1165
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia
Contact:

Re: mouseMoveCaptured with right mouse button - bug?

Post 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
Post Reply