If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
RUBY - XY Surface
23 posts
• Page 1 of 3 • 1, 2, 3
RUBY - XY Surface
Dear all,
I'm practicing RUBY and feel a bit frustrated (even after peeping into 'FlowStone GURU' which is amazing...).
I'd built this XY surface pad, but mouse is still 'hand shaped' even after mouse is dragged out of draw area.
How can I limit this? I couldn't get to changing any of the methods correctly...
appreciated !
I'm practicing RUBY and feel a bit frustrated (even after peeping into 'FlowStone GURU' which is amazing...).
I'd built this XY surface pad, but mouse is still 'hand shaped' even after mouse is dragged out of draw area.
How can I limit this? I couldn't get to changing any of the methods correctly...
appreciated !
- Attachments
-
- XY_surface.fsm
- (1.24 KiB) Downloaded 1065 times
- Rocko
- Posts: 186
- Joined: Tue May 15, 2012 12:42 pm
Re: RUBY - XY Surface
Just replace
by
See also http://www.dsprobotics.com/support/viewtopic.php?f=3&t=3507
- Code: Select all
mouseLUp
by
- Code: Select all
mouseLUpCaptured
See also http://www.dsprobotics.com/support/viewtopic.php?f=3&t=3507
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: RUBY - XY Surface
Thanks Tulamide, appreciated. Please notice that it doesn't seem to do the trick..
I had changed the 'LUp' to 'LUpCatpured' and the perfromance is the same. Even if mouse is out of 'view' area, the XY float values still change.
Please see attached schematic.
On the 'FlowStone GURU' forum, 'basic switch', you mention:
How can I achieve limiting the 'isinmousepoint to the size of view screen only? I can't get the syntax right.
Thanks,
Rocko
I had changed the 'LUp' to 'LUpCatpured' and the perfromance is the same. Even if mouse is out of 'view' area, the XY float values still change.
Please see attached schematic.
On the 'FlowStone GURU' forum, 'basic switch', you mention:
Another important method we will need is “isInMousePoint”, this tells Flowstone that our Ruby component wants to enable mouse actions (click, drag ect). This is very important! If you forget to define this method but implement other mouse methods such as “mouseLDown” they will not work. So if you need mouse events always remember “isInMousePoint”. The method returns either true or false. You can assign the mouse area to a specific region using this method, you just check if the x and y values are within an area and return true or else return false. In this simple button example we will not worry about areas and instead just return true, now the whole of the button area will be clickable.
How can I achieve limiting the 'isinmousepoint to the size of view screen only? I can't get the syntax right.
Thanks,
Rocko
- Attachments
-
- XY_surface_v2.fsm
- (1.35 KiB) Downloaded 1051 times
- Rocko
- Posts: 186
- Joined: Tue May 15, 2012 12:42 pm
Re: RUBY - XY Surface
Hey Rocko,
sorry for the confusion, I was just reacting to
This lead me to think you had the usual issue of not receiving the mouse up message. I've done 3 in-depth tutorials about Ruby, but the one you quote is by Exo
Now that you described your issue more clearly, I hope the attached fsm will solve it. You can't use the "isInMousePoint" method for that. The method is only reporting outside of any "captured" methods. What you need is to tell Ruby in the "mouseMoveCaptured" method, what exactly you want to output. You do that using the if-statement. The example should be self-explanatory.
sorry for the confusion, I was just reacting to
I'd built this XY surface pad, but mouse is still 'hand shaped' even after mouse is dragged out of draw area.
This lead me to think you had the usual issue of not receiving the mouse up message. I've done 3 in-depth tutorials about Ruby, but the one you quote is by Exo
Now that you described your issue more clearly, I hope the attached fsm will solve it. You can't use the "isInMousePoint" method for that. The method is only reporting outside of any "captured" methods. What you need is to tell Ruby in the "mouseMoveCaptured" method, what exactly you want to output. You do that using the if-statement. The example should be self-explanatory.
- Attachments
-
- XY_surface_v2[tula].fsm
- (1.41 KiB) Downloaded 1035 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: RUBY - XY Surface
Hi,
Thanks appreciated. I'm learning the syntax... So, thank you and Exo for the explanations.
With the new schematic, if I drag the 'black dot' all the way out of the 'view' it is still operative at least in one axis. This is because of the build of the 'if' statement.
My question is if there is a good way for the mouse to stop being 'hand shaped' and stop being responsive (black dot stays at last coordinate) once the mouse is dragged out of the view itself.
Kind of:
if (mouse is out of view) then (pointer = arrow and black_dot at last position)
I'll be playing with it, but if you have any hints, please share - thanks !
Thanks appreciated. I'm learning the syntax... So, thank you and Exo for the explanations.
With the new schematic, if I drag the 'black dot' all the way out of the 'view' it is still operative at least in one axis. This is because of the build of the 'if' statement.
My question is if there is a good way for the mouse to stop being 'hand shaped' and stop being responsive (black dot stays at last coordinate) once the mouse is dragged out of the view itself.
Kind of:
if (mouse is out of view) then (pointer = arrow and black_dot at last position)
I'll be playing with it, but if you have any hints, please share - thanks !
- Rocko
- Posts: 186
- Joined: Tue May 15, 2012 12:42 pm
Re: RUBY - XY Surface
Haha, now we come closer to the real goal. Ok, here's a few things:
The black dot is only out of the view, because you start the draw at the mouse position. If you want the dot to be visible at all times, you must reduce the mouse area by the width and height of the dot.
I would not recommend to stop any movement as long as the mouse is outside the view. Just think of this: The mouse is just at the center of the view. Now the user moves his mouse ultra-fast (no problem with a high dpi mouse). The next position that the system reports to Ruby will be out of the view, so no movement of the dot at all is happening. This will confuse the user, as he will think that the control doesn't work.
If you want to do it that way nevertheless, you again just have to use if-statements that reflect your wishes. But you can't reset the mouse cursor postion, that is system controlled. You can only influence what's drawn in the view.
It is easy, once you are used to. First part
"if (mouse is out of view)"
The user manual tells you everything about Ruby in chapter 8. One thing mentioned there is the class method "getViewSize". It returns an array in this form [w, h]. You can use that to only allow any dot movement, when the mouse is inside that rectangle:
Now the dot is not moved anymore whenever the mouse is outside the view.
You can change the mousecursor appearance with the method "mouseCursor x, y", as stated in the user manual. However, this will normally only be active, if the mouse is inside the view. You could try it, but I don't think it works.
The black dot is only out of the view, because you start the draw at the mouse position. If you want the dot to be visible at all times, you must reduce the mouse area by the width and height of the dot.
I would not recommend to stop any movement as long as the mouse is outside the view. Just think of this: The mouse is just at the center of the view. Now the user moves his mouse ultra-fast (no problem with a high dpi mouse). The next position that the system reports to Ruby will be out of the view, so no movement of the dot at all is happening. This will confuse the user, as he will think that the control doesn't work.
If you want to do it that way nevertheless, you again just have to use if-statements that reflect your wishes. But you can't reset the mouse cursor postion, that is system controlled. You can only influence what's drawn in the view.
if (mouse is out of view) then (pointer = arrow and black_dot at last position)
It is easy, once you are used to. First part
"if (mouse is out of view)"
The user manual tells you everything about Ruby in chapter 8. One thing mentioned there is the class method "getViewSize". It returns an array in this form [w, h]. You can use that to only allow any dot movement, when the mouse is inside that rectangle:
- Code: Select all
if x.between?(0, getViewSize[0]) and y.between?(0, getViewSize[1])
# do your code
end
Now the dot is not moved anymore whenever the mouse is outside the view.
You can change the mousecursor appearance with the method "mouseCursor x, y", as stated in the user manual. However, this will normally only be active, if the mouse is inside the view. You could try it, but I don't think it works.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: RUBY - XY Surface
Thanks for the answer. Very good points...
This is what I have done then:
This is what I have done then:
- Code: Select all
@x_size=getViewSize[0]-1
@y_size=getViewSize[1]-1
def isInMousePoint x,y
true
end
def mouseLDown x,y
captureMouse
end
def mouseMoveCaptured x,y
if (x<0) then self.output 0,0 else
if (x>@x_size) then self.output 0,@x_size else self.output 0,x end
end
if (y<0) then self.output 1,0 else
if (y>@y_size) then self.output 1,@y_size else self.output 1,y end
end
end
def mouseLUpCaptured x,y
releaseMouse
end
- Rocko
- Posts: 186
- Joined: Tue May 15, 2012 12:42 pm
Re: RUBY - XY Surface
Hi,
In my code, I have many repeating instances such as:
getViewSize[1]*0.5
To cut down this small calculation, as well as make the code more readable, I was thinking of declaring this at start of code:
@SY = getViewSize[1]*0.5
However, this crashes the RUBY code when I try to restart it.
On a blank RUBY code, it performs OK...
What am I missing ??
In my code, I have many repeating instances such as:
getViewSize[1]*0.5
To cut down this small calculation, as well as make the code more readable, I was thinking of declaring this at start of code:
@SY = getViewSize[1]*0.5
However, this crashes the RUBY code when I try to restart it.
On a blank RUBY code, it performs OK...
What am I missing ??
- Rocko
- Posts: 186
- Joined: Tue May 15, 2012 12:42 pm
Re: RUBY - XY Surface
is it the capital letters for variable name? [@sy instead of @SY]
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: RUBY - XY Surface
RJ is right, in Ruby you have to use lower case as the first letter of variables.
But the issue, I think, is that you use getViewSize before the view is defined. That would explain why it crashes after restart. Flowstone initializes a schematic after load in the order that you built it. If you first place a RubyEdit in the schematic and then a module with an mgui, the RubyEdit will be initialzed first. If something like that is the case, cut the RubyEdit and paste it back in, then save. Now the order is module -> RubyEdit. If that still leads to crashes, you have to share your code, so that we are able to inspect it.
But the issue, I think, is that you use getViewSize before the view is defined. That would explain why it crashes after restart. Flowstone initializes a schematic after load in the order that you built it. If you first place a RubyEdit in the schematic and then a module with an mgui, the RubyEdit will be initialzed first. If something like that is the case, cut the RubyEdit and paste it back in, then save. Now the order is module -> RubyEdit. If that still leads to crashes, you have to share your code, so that we are able to inspect it.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
23 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 61 guests