Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Recent issues

Article Preview

Buy Now

Issue 2.5


Pop-up Palettes

Learn to create a pop-up color selection palette

Issue: 2.5 (May/June 2004)
Author: Thomas Reed
Author Bio: Thomas Reed has been programming as a hobbyist for more than 20 years, and fell in love with the Mac in 1984.
Article Description: No description available.
Article Length (in bytes): 10,115
Starting Page Number: 30
Article Number: 2514
Resource File(s):

Download Icon 2514.zip Updated: 2013-03-11 19:07:58

Related Link(s): None

Excerpt of article text...

A pop-up palette is similar to a pop-up menu, and usually consists of a grid of graphical items from which the user can select. Such palettes have been found in many applications over the years. One popular example is a palette of paint tool options that appears when you click a tool in a paint program. I have seen many different implementations of the pop-up palette in REALbasic, but many fall short of expectations. In this article, I will show you how to create a very dynamic palette.

Some approaches to the pop-up palette draw the palette within a control in the window containing the initiating control. This approach has a number of serious limitations, with control order issues, handling of clicks outside the palette, and available window space being the most significant. For these reasons, I prefer to implement pop-up palettes as a separate window.

Let's think for a moment about how the palette should look and behave. Although I recommended creating the palette as a window, it is immediately obvious that the palette should not have a title bar. A floating palette with a title bar is a perfectly acceptable object, but that is not what we are trying to achieve. Thus, we must set the window's frame to type "4 - Plain Box". This eliminates as much of the window's interface as possible, with the only part of the window outside the content region being a one pixel wide black line around the edge.

The palette should behave somewhat like a sticky menu. A single click on some control should open it, and a single click within the palette should close it. A single click outside the palette should also close the palette, in this case without making any selection.

To implement the palette, we'll create a window called PaletteWindow. To this window we will add a function named ShowPalette. Its purpose will be to initialize the palette, show the window using ShowModal and, when closed, return a value indicating what item was selected. The details, including the return type, will need to wait until we have fleshed out the palette, but the basic functionality will be:

Function ShowPalette() as SomeResult

...End of Excerpt. Please purchase the magazine to read the full article.