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

[Ruby] Circular Mouse Checks

Post any examples or modules that you want to share here

[Ruby] Circular Mouse Checks

Postby tulamide » Mon Nov 23, 2015 3:05 pm

Nowadays GUIs have more and more circular objects, be it knobs or buttons. If you have more than one object in your view and want to detect mouse clicks on them, you have to create a method for it.

You can get away with a rectangular check, which is setting up the boundaries of a virtual rectangle around the object and then testing if the mouse position is inside that virtual rectangle.

But you can also check circular. If you draw a circle it has a center point and a radius. The trick is to test if the mouse position is inside the radius.

The schematic will show you how to do a circular check and why it is an advantage when dealing with circular objects.
Attachments
check_circular.fsm
(1.04 KiB) Downloaded 1305 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] Circular Mouse Checks

Postby RJHollins » Mon Nov 23, 2015 7:55 pm

Hi T,

Man , that works really well. Cool.
8-)
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: [Ruby] Circular Mouse Checks

Postby Nubeat7 » Mon Nov 23, 2015 7:58 pm

thats very useful, if you would like to play this with any shape you like, there exists a comfortable methode,
the isVisible methode for graphicpaths (userguide p.162)

with this methode you can check if a point is inside a graphicpath, here is a small example based on the one you posted

greez
Attachments
check_shape.fsm
(707 Bytes) Downloaded 1350 times
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: [Ruby] Circular Mouse Checks

Postby tulamide » Mon Nov 23, 2015 10:26 pm

Yes, I know about this method, and it is nice to have. The thing is, polygon checks are much more cpu-intensive. If this is not a concern, then, this goes to everyone reading here, make use of it. If it is a concern, rectangular and circular checks are cheaper on cpu.

@RJHollins, thank you :)
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: [Ruby] Circular Mouse Checks

Postby RJHollins » Mon Nov 23, 2015 11:31 pm

Good stuff Guys.

Always appreciate the 'education' too !
8-)
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: [Ruby] Circular Mouse Checks

Postby Nubeat7 » Tue Nov 24, 2015 9:32 am

tulamide wrote:Yes, I know about this method, and it is nice to have. The thing is, polygon checks are much more cpu-intensive. If this is not a concern, then, this goes to everyone reading here, make use of it. If it is a concern, rectangular and circular checks are cheaper on cpu.

@RJHollins, thank you :)


thanks for this info, good to know!
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: [Ruby] Circular Mouse Checks

Postby Walter Sommerfeld » Tue Nov 24, 2015 2:26 pm

Perfect 4 my Endless knob with it's center button...


Keep on doing!

cheers,
Walter
User avatar
Walter Sommerfeld
 
Posts: 249
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany

Re: [Ruby] Circular Mouse Checks

Postby Tronic » Tue Nov 24, 2015 2:54 pm

8-)
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: [Ruby] Circular Mouse Checks

Postby RJHollins » Tue Nov 24, 2015 6:21 pm

Walter Sommerfeld wrote:Perfect 4 my Endless knob with it's center button...


Keep on doing!

cheers,
Walter

Hmmm :) Are you saying a way to control dual concentric rings ?? :o Like an API 5500 eq.

that would be so useful.
8-)
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: [Ruby] Circular Mouse Checks

Postby Nubeat7 » Tue Nov 24, 2015 9:33 pm

RJHollins wrote:..control dual concentric rings ??..


for this you can use the widen methode on an arc path when you are using a pen to draw a path and you will need only the area from the pen line...
here is a very basic schematic to do this, but also tulamides methode would work, its without any eventhandling or presetmanagement, but this shouldn't be to hard..
Attachments
double_knob.fsm
(1.04 KiB) Downloaded 1284 times
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Next

Return to User Examples

Who is online

Users browsing this forum: No registered users and 49 guests