Help! To maintain sanity! (Popup windows)

I’ve been trying for some time to figure out how to create a floating popup window on Mac.

I finally found a project (from someone else) that had such a popup window. I narrowed things down until I have two identical windows. One I created and the borrowed one. The problem is my widow displays a title bar but the borrowed one doesn’t.

Either there is some magic involved, or I’m missing something obvious. or I’m loosing it…


Here is the project.

You aren’t loosing it. popup1 sure looks very strange. Even after changing to the window type to DocumentWindow the window didn’t change from PlainBox. I deleted the window. Copied popup2 to popup1 and the 2 windows were identical.

I know but. I’m trying to figure out how to reproduce a floating plain box. The app I got the Popup1 from obviously wanted a floating plain box.

What about Floating Wndow ?
Because of its title bar ?

OK after a night of rest I was able to figure it out.

I saved as a text project, and compared to output in notepad. Popup1 has MacProcID set to 1040. That was my clue.

I tried changing the setting the MacProcID but I could not figure out how to set it in IDE, and changing it at run time didn’t have the desired affect. Finally I made the change manually in the text project, and saved as a binary project. The change stuck but I was asked to reset my appid when opened the project. Strange.

Being relatively new to Mac it seems there are some unspoken things that people just know (and I don’t). Learning is hard…

The documentation states it can be done in the IDE only. How? It doesn’t say, and I’m not intelligent enough to figure it out (yet).

The MacProcID is really really old. I seem to remember that this was exposed in the old times.

For Cocoa apps you either want a window with a titlebar or an overlay window.

How to create an overlay window???

Sorry, senior moment. Popover window is the correct name. The MBS plugin can do this ( You want this for filtering, correct?

I’m not sure if you need this. Microsoft Office uses a black HUD style window. Have you tried with a simple container control and show/hide it as needed?

i’m creating a custom combobox with a dropdown list. A container control wouldn’t work because a container is not able to protrude
beyond the edge of the parent window. Since this is a custom control I would prefer to use 100% Xojo code.

Just as on Windows you’ve had to use a couple declares you’ll need a couple on macOS
To remove the top title bar etc you need a declare into NSWindow.SetStyleMask


Something like this in the open event of your window

Declare Sub setStyleMask Lib "Cocoa.framework" selector "setStyleMask:" (obj_id As Integer, styleMask As UInt32)
setStyleMask self.Handle, 0

Thanks Norman I’m really new to Mac declares. Your declare hides the titlebar as well as the shadow.
In the meantime I was experimenting and found that the same declare but specifying 65 instead of 0 hides the title bar and keeps the shadow.

You can add together all the bits of a style mask and come up with lots of variations

From NSWindow.h

typedef NS_OPTIONS(NSUInteger, NSWindowStyleMask) {
    NSWindowStyleMaskBorderless = 0,
    NSWindowStyleMaskTitled = 1 << 0,
    NSWindowStyleMaskClosable = 1 << 1,
    NSWindowStyleMaskMiniaturizable = 1 << 2,
    NSWindowStyleMaskResizable	= 1 << 3,
    /* Specifies a window with textured background. Textured windows generally don't draw a top border line under the titlebar/toolbar. To get that line, use the NSUnifiedTitleAndToolbarWindowMask mask.
    NSWindowStyleMaskTexturedBackground = 1 << 8,
    /* Specifies a window whose titlebar and toolbar have a unified look - that is, a continuous background. Under the titlebar and toolbar a horizontal separator line will appear.
    NSWindowStyleMaskUnifiedTitleAndToolbar = 1 << 12,
    /* When set, the window will appear full screen. This mask is automatically toggled when toggleFullScreen: is called.
    NSWindowStyleMaskFullScreen NS_ENUM_AVAILABLE_MAC(10_7) = 1 << 14,
    /* If set, the contentView will consume the full size of the window; it can be combined with other window style masks, but is only respected for windows with a titlebar.
     Utilizing this mask opts-in to layer-backing. Utilize the contentLayoutRect or auto-layout contentLayoutGuide to layout views underneath the titlebar/toolbar area.
    NSWindowStyleMaskFullSizeContentView NS_ENUM_AVAILABLE_MAC(10_10) = 1 << 15,
    /* The following are only applicable for NSPanel (or a subclass thereof)
    NSWindowStyleMaskUtilityWindow			= 1 << 4,
    NSWindowStyleMaskDocModalWindow 		= 1 << 6,
    NSWindowStyleMaskNonactivatingPanel		= 1 << 7, // Specifies that a panel that does not activate the owning application
    NSWindowStyleMaskHUDWindow NS_ENUM_AVAILABLE_MAC(10_6) = 1 << 13 // Specifies a heads up display panel

Thanks a bunch Norman.

I had to google << to find out how to calculate. Pardon the ignorance.
It really is painful to learn the basics because it’s so elementary that everyone assumes you already know it.

ah … bitwise.shiftleft is <<

Just for clarity in this thread for anyone in the future, Beatirx is right, MacProcID is really old.
It’s only available for Carbon.