Article Preview
Buy Now
FEATURE
Designing a Recent Items Submenu
Issue: 2.1 (August/September 2003)
Author: Charles Yeomans
Author Bio: Charles Yeomans is a compulsive refactorer.
Article Description: No description available.
Article Length (in bytes): 24,324
Starting Page Number: 24
Article Number: 2112
Resource File(s):
2112.zip Updated: 2013-03-10 14:52:17
Related Link(s): None
Excerpt of article text...
Most document-based applications should offer a Recent Items submenu that allow users to quickly open recently-opened files -- or, as buzzword-loving geeks might say, to allow users to exploit locality of reference. Adding such a feature isn't difficult, but since it's something that you might want to use in multiple projects, it's worth spending some time on it. In this article, I'll show how to write some classes that allow you to more or less plug this capability into your projects. Along the way, I'll discuss some of my design and implementation decisions.
The Problem
The first step is to get a clear description of the problem to solve. What I want is a menu item, Open Recent, and a submenu of it that lists recently-opened files. Choosing a submenu item should open the file just as if I had chosen the file from the Open dialog. I would also like to be able to provide for a user-customizable limit on the number of recently-opened files displayed, and I'd like the allow the user to clear the submenu. And I'd like to be able to open a recently-opened file even if it has been moved. Finally, I'd like to save the list of recently-opened files between runs.
...End of Excerpt. Please purchase the magazine to read the full article.