Special

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!

Article Preview


Buy Now

Issue 2.5

COLUMN

Design Eye for the Programming Guy

Rethinking the PopupMenu Interface

Issue: 2.5 (May/June 2004)
Author: Charles Yeomans
Author Bio: Charles Yeomans is a software developer in Lexington, Kentucky.
Article Description: No description available.
Article Length (in bytes): 5,154
Starting Page Number: 35
Article Number: 2517
Related Link(s): None

Excerpt of article text...

Let's consider a familiar example, the PopupMenu class. PopupMenu.ListIndex returns the index of the selected row, if one has been selected; otherwise it returns -1. Perhaps this seems like a reasonable, even natural design. I claim that it is not.

The problem is that PopupMenu.ListIndex is telling you two things; first, whether or not a menu item has been selected, and, second, the index of the selected row, if a row has been selected. It does this through the use of a magic value; that is, it returns -1 to signify that no row has been selected. The result is code like this:

If PopupMenu1.ListIndex > -1 then

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