GLX Application FrameworkGLX Application Framework 1.2Application HelpersHow Can I Add An "Open Recent" Item To My File Menu?

How Can I Add An "Open Recent" Item To My File Menu?

The framework provides handlers for storing, displaying and retrieving recent files that your application has opened. The recent files are stored in your application's preference file.

Available Handlers

Here you see the five handlers available for working with recently opened files. The API allows for adding and removing files from a list of recently opened files.

The API also formats the list of files for display in a menu (1) and provides a handler to retrieve a full path to a file from a truncated file name that appears in a menu (2).

Creating an "Open Recent" Menu Item

This code snippet demonstrates how you might create an "Open Recent" menu item in the File menu.

1) Build menu in mouseDown handler sent to group assigned as the menubar of stack.

2) Start with a predefined default file menu. Make sure there that "Open Recent" appears as a line in the menu.

3) Retrieve list of recently opened files for your application. Each line will contain the name of the file that was recently opened. If two files have the same name then the parent folder(s) will be added in order to make the name unique among the lines of the list.

4) Put list of recently opened files after the "Open Recent" menu item.

Opening a Recently Opened File

When the user selects a recently opened file from the File menu you need to determine the full path to the file before you can process the request.

1) Determine if the user selected a sub-menu of "Open Recent".

2) If they did then the selected item is the key that is used to retrieve the absolute file path. Pass to glxapp_pathFromRecentlyOpenedKey() in order to get the absolute file path.

You can now pass the file to one of your UI handlers for processing.

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.