Support

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

mouse over boolean output ruby?

For general discussion related FlowStone

mouse over boolean output ruby?

Postby Nubeat7 » Fri Dec 12, 2014 6:35 pm

hi all, just have a quick question, what's the easiest way to output a mouse over boolean in ruby?
i just used this
Code: Select all
def isInMouseArea (x,y,area)
   x1, y1 ,x2 , y2 = area
   x2 += x1
   y2 += y1
   x.between?(x1,x2) && y.between?(y1,y2)
end
def isInMousePoint(x,y)
   if isInMouseArea(x,y,@area)
       output 'mouseOver',true
       return true
   end
   output 'mouseOver',false
   return false
end

but isn't there an easier way?
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: mouse over boolean output ruby?

Postby tulamide » Fri Dec 12, 2014 7:38 pm

Only another way, but not easier. You could activate mouse move on the mgui prim and in ruby then use

(Pseudo Code)
Code: Select all
def mouseMove x, y
    if (you're area code) then output true else output false end
end
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: mouse over boolean output ruby?

Postby Nubeat7 » Fri Dec 12, 2014 9:52 pm

thanks tulamide,

another question, does there exist a fast way to get the view area? something like "getViewArea" ? or do i need to use getViewSize for it..
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: mouse over boolean output ruby?

Postby tulamide » Sat Dec 13, 2014 4:35 pm

The latter. Unfortunately, no position offset is returned by any method I know of. It's always local coordinates (Top-left corner will always be [0, 0], no matter where that view is positioned within its parent.

I don't know where your question leads to, but here are some tips.

4-element-array building from getViewSize:
Code: Select all
area = [0, 0] + getViewSize

Code: Select all
area = Array.new(2,0) + getViewSize

Code: Select all
area = 0, 0, getViewSize
area.flatten!


4 objects assignment:
Code: Select all
x, y, w, h = 0, 0, getViewSize[0], getViewSize[1]
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: mouse over boolean output ruby?

Postby TheOm » Sat Dec 13, 2014 7:27 pm

There's also the splat operator ('*'), which converts an enumerable to an argument list.
Code: Select all
view_area = 0.0, 0.0, *getViewSize
TheOm
 
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: mouse over boolean output ruby?

Postby Nubeat7 » Mon Dec 15, 2014 2:46 pm

thank you, tulamide and om, so many ways to do one thing, good to see this different ways :)
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna


Return to General

Who is online

Users browsing this forum: No registered users and 70 guests