realbasic.rect?

Why are they still called “realbasic.rect”? :slight_smile:

Because they’re part of the old framework. Xojo.??? will be the namespace for the new framework. Coming soon.

How do you use it ?

At first, I took it for a Rect container (left, Top, Width, Height), but I was wrong.

Tim, I guess it’s not as easy as search and replace. Also I was curious why its not just called a “Rect”.

Emile, that is what its used for (a rect container). I use it when drawing custom controls and need to keep track of certain areas that I’ve drawn.

Joseph,

thank you for your answer.

Can you elaborate a bit ?

The rect object can be thought about as a canvas that is invisible, and has no parent.
If you need to hold the four bounding properties of ‘something’, a rect cab do it without the overheads of an actual visible object.

You could do that with a STRUCT of 4 integers or doubles.

The rect class adds extra goodies such as a computed property giving the horizontal and vertical centres.
(Otherwise you would be using left + width/2 for example)

And methods to take one rect and split it into 2 at a point.

Possibly one of the most useful is the intersect method… you can use this both to determine if two rects overlap, and if so, generate a new rect representing the overlapping area.

Here’s a simple project example highlighting a couple of the features Jeff is talking about.

https://www.dropbox.com/s/ojksi3tighanlg3/rectSample.xojo_binary_project

I have also wondered why not just call it a “Rect” as opposed to “Realbasic.Rect” or possibly “Xojo.Rect”.

I suppose because Rect was introduced late and would have broken a lot of code, so they decided to put it into a module (to act as a namespace).

You can call it just “Rect”. The Realbasic vs. Xojo aspect will be old vs. new framework. But that’s not here yet.

Hi all,

thank you for your answers / demo project (Joseph).