Skip to content

popupwinlib

This library shows a popup menu: a list of items in a borderless window with a bevelled frame, in the font of the screen, opened at the top left corner of a screen. Moving the mouse over an item highlights it; an item with a sub menu opens the sub menu at once, in a window to the right of the item. A mouse button closes all menus again.

The program builds the menu itself in memory, as a list of items. Each item starts with these fields:

OffsetSizeContents
0longthe address of the next item, 0 for the last
4longthe address of its text, a string that ends in a zero byte; 0 makes the item a separator line
8wordnot used by the library
10wordnot used by the library
12longthe address of the first item of its sub menu, 0 for none

Used as a function, PopUpWindow returns the address of the item chosen, or 0 if none was, so the program tells the items by their addresses.

The fixed bugs of the library are listed in Fixes in popupwinlib.

Library number 16.

Commands

PopUpInit

Gives the menu windows a message port if they have none. The library makes one when the program starts, so this command is not needed.

Statement. Help text: -- initialise the popup window system
Arguments: .w

The argument is not used.

PopUpWindow

Shows the menu whose first item is at the address *items at the top left corner of the screen object Screen#, and returns when a mouse button is pressed. As a function it returns the address of the item chosen, or 0 if none was.

Statement or function, result .l. Help text: Screen#,*items
Arguments: .w, .l

The item chosen is the one highlighted when the mouse button is pressed, in the menu or in one of its sub menus. Without free memory for a menu, or if a window cannot be opened, the whole menu closes at once and the function returns 0.

On Kickstart 1.x a sub menu whose window does not fit on the screen, at its right or bottom edge, cannot open either, so the whole menu closes there.