Copyright (c) 2012-2016 Hyperion Entertainment and contributors.

BOOPSI Popup Menus - Part 3

From AmigaOS Documentation Wiki
Jump to: navigation, search

Author

Simon Archer
Copyright (c) 2011 Simon Archer
Used by Permission

Introduction

In parts one and two, we took a look at the new "popup" menu feature of window.class and what extra items could be added and how to deal with them. Since then, some extra features have been added which allows Snapshotting and Unsnapshotting of window.class objects. This will require at least version 53.54, and will be subject to a future update. For now, we shall discover how this feature is used in readiness for that update.

Overview

As we saw in part one, there are a number of "default" items we can show in the menu, and we can add items for our own use. We can also enable an automatic way to save window size and position. In order to do this, we need to specify the WINDOW_UniqueID tag when the window object is created (OM_NEW). While this tag is not directly connected with the windows popup menu, it does affect the menu and the amount of default items. WINDOW_UniqueID tells window.class that this object has a name, specified by the tag data. This should be a unique name within your application. It is highly possible that your application may open more than one window, and each may have their size and position saved separately by ensuring the string you supply is unique. For example, specifying "MAIN_Window" as the UniqueID for the main window, and "LIST_Window" for another will allow your users to specify different positions and sizes for each window object.

A Closer Look

Calculator menus.png

As an example of this, we shall use the Calculator utility. Calculator has two modes, and each of these has a separate UniqueID, this means that we can actually save the position and size for each mode. Here you can see we have some extra menu items, namely:
Snapshot
This will save the window objects size and position to a file stored in ENV(ARC):sys/WindowData. A drawer will be created there with the same name as your application, and the data for this object will be saved inside it with the UniqueID you gave the window object.
Unsnapshot
Just as the data was saved above, this option will remove the size and position data, effectively making the window object use the defaults again.
Restore
This option reloads the saved snapshot data and places the window back to that position. This is useful if you have moved or resized the window, and want to put it back to the last saved position/size.

That concludes our look into the window.class popup menu, we hope you found it useful.