The macro below draws a hotspot button at a specified location. I use it to create a control panel for multilevel floorplans that use layers for levels. The following variables must be set before running it:
  • "pButtonL" and "pButtonH": point variables containing lower left and upper right corners of the hotspot button,
  • "nCurLvl": a numeric variable containing the current structure level number.

Code:
MACRO ML_DRAWBTN
sheet MAP BORDER
setlayer BUTTONS
color 15
fstyle Hollow
box pButtonL pButtonH
The box drawn above will be the button's visible frame.
Code:
gl sMacCmd ~gn nCur
apnd sMacCmd Lvl
apnd sMacCmd;
apnd sMacCmd nCurLvl
apnd sMacCmd;
apnd sMacCmd GoCur
apnd sMacCmd Lvl
apnd sMacCmd;
color 2
tspech 1
actionm sMacCmd
pButtonL pButtonH
"GoCurLvl" is a macro that converts the level number into a layer name which it then makes current. Note how I split the variable and macro names while building the macro command string (sMacCmd) so they don't expand and terminate the string with a delimiter.
Code:
sheet TEXT
color 15
getx vX1 pButtonL
gety vY1 pButtonL
getx vX2 pButtonH
gety vY2 pButtonH
gp pButtonC (vX1+vX2)/2,(vY1+vY2)/2
tspech (vY2-vY1)/2
textm nCurLvl
pButtonC
The above code finds the center of the hotspot and places the level number there as a text label. On my maps the TEXT sheet is above the MAP BORDER one. Note how the text height is half the button height.
Code:
sheet MAP BORDER
GoCurLvl
color 4
fstyle Solid
box pButtonL pButtonH
ENDM
The above code draws a yellow box that "backlights" the button of the currently active level.

--

Dalton "who hopes that this idea stays clever" Spence