tips
[Top] [All Lists]

REALbasic Tip: Using colors in your code

To: REALbasic-tips at lists dot realsoftware dot com
Subject: REALbasic Tip: Using colors in your code
From: Geoff Perlman <geoff at realsoftware dot com>
Date: Thu, 6 Apr 2006 15:57:24 -0500
Cc:
Delivered-to: REALbasic-tips at lists dot realsoftware dot com
If you have used colors in your code (for example when assigning a value to the ForeColor property of the graphics class), it can be difficult to determine the right RGB values to use with the RGB function. Luckily, there are two techniques you can use that make this easier:

When assigning the color, rather than using the RGB function, right click (control-click on Macintosh) in the Code Editor and choose Insert Color from the contextual menu. This displays a color picker. Choose a color and REALbasic will insert the hex value of the color right into your code. This is quick but it does result in a value that doesn't express the color. For example, setting the ForeColor property to a reddish color looks like this:

g.ForeColor = &cE21717

Another technique which will make your code more readable is to use color constants. Add a constant to the window or class you are using and choose Color as its type. A color box will appear that lets you choose a color from a color picker. You can then give the constant a meaningful name and use it in your code. For example, that reddish color I mentioned earlier could appear in your code like this:

g.ForeColor = Reddish

Note: color hex values are supported in REALbasic 5.5 but the Insert Color contextual menu and color constants are available only in REALbasic 2005 or later.
--
Geoff Perlman
President and CEO
REAL Software, Inc.


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>
  • REALbasic Tip: Using colors in your code, Geoff Perlman <=