Platforms to show: All Mac Windows Linux Cross-Platform

MAAttachedWindowMBS class   Deprecated

Super class: NSWindowMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Window MBS MacExtras Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
This item is deprecated and should no longer be used.
A class for attached windows in Cocoa.

For Mac OS X 10.7 you can use NSPopoverMBS. This class does something similar for Mac OS X 10.4 to 10.7.

Base on MAAttachedWindow code by Matt Gemmell.
See his website http://mattgemmell.com/

Below are the positions the attached window can be displayed at.

ote that these positions are relative to the point passed to the constructor, e.g. MAPositionBottomRight will put the window below the point and towards the right, MAPositionTop will horizontally center the window above the point, MAPositionRightTop will put the window to the right and above the point, and so on.

You can also pass MAPositionAutomatic and the attached window will try to position itself sensibly, based on available screen-space.

Notes regarding automatically-positioned attached windows:

(a) The window prefers to position itself horizontally centered below the specified point. This gives a certain enhanced visual sense of an attachment/relationship.

(b) The window will try to align itself with its parent window (if any); i.e. it will attempt to stay within its parent window's frame if it can.

(c) The algorithm isn't perfect. :) If in doubt, do your own calculations and then explicitly request that the window attach itself to a particular side.

Notes regarding accessor methods:

1. The border is drawn inside the viewMargin area, expanding inwards; it does not increase the width/height of the window. You can use the BorderWidth and ViewMargin methods together to achieve the exact look/geometry you want. (viewMargin is the distance between the edge of the view and the window edge.)

2. The specified setter methods are primarily intended to be used _before_ the window is first shown. If you use them while the window is already visible, be aware that they may cause the window to move and/or resize, in order to stay anchored to the point specified in the initializer. They may also cause the view to move within the window, in order to remain centered there.

Note that the HasArrow method can safely be used at any time, and will not cause moving/resizing of the window. This is for convenience, in case you want to add or remove the arrow in response to user interaction. For example, you could make the attached window movable by its background, and if the user dragged it away from its initial point, the arrow could be removed. This would duplicate how Aperture's attached windows behave.

3. drawsRoundCornerBesideArrow takes effect when the arrow is being drawn at a corner, i.e. when it's not at one of the four primary compass directions. In this situation, if drawsRoundCornerBesideArrow is true (the default), then that corner of the window will be rounded just like the other three corners, thus the arrow will be inset slightly from the edge of the window to allow room for the rounded corner. If this value is false, the corner beside the arrow will be a square corner, and the other three corners will be rounded.

This is useful when you want to attach a window very near the edge of another window, and don't want the attached window's edge to be visually outside the frame of the parent window.

4. Note that to retrieve the background color of the window, you should use the windowBackgroundColor method, instead of backgroundColor. This is because we draw the entire background of the window (rounded path, arrow, etc) in an NSColor pattern image, and set it as the backgroundColor of the window.
Subclass of the NSWindowMBS class.

Position constants

Constant Value Description
MAPositionAutomatic 12 automatic
MAPositionBottom 1 bottom
MAPositionBottomLeft 10 bottom left
MAPositionBottomRight 11 bottom right
MAPositionLeft 0 left
MAPositionLeftBottom 5 left bottom
MAPositionLeftTop 4 left top
MAPositionRight 2 right
MAPositionRightBottom 7 right bottom
MAPositionRightTop 6 right top
MAPositionTop 3 top
MAPositionTopLeft 8 top left
MAPositionTopRight 9 top right

Super class NSWindowMBS

Super class NSResponderMBS

This class has no sub classes.

Some examples using this class:

Blog Entries

Release notes


The items on this page are in the following plugins: MBS MacBase Plugin, MBS MacExtras Plugin.


LTCSMPTETimecodeMBS   -   MacAliasMBS


The biggest plugin in space...