NSStatusItem Popup?

Hi,
anyone have any pointers how I create a popup window (as shown in the following link)?
link text

I have my StatusItem all working, but know how to place a window under the NSStatusItem, but I have no idea how to make the window look like a popup (with the little triangle).

Thanks.

dtplugins has this. You can create a container with all sorts of things (any control) and then put it in a popupmenu.

http://www.dethomsoft.com/DtPlugins.html

Unfortunately that does not work on Xojo 2013 r3.1 :frowning:

Lay out your window the way you want (style Plain Box), make it transparent, and then draw the shape yourself in the paint event (I do it with a figureshape)…

I use this to make the window transparent on OSX, I wish I could credit where I got it but I don’t recall where it’s from at the moment:

    //Just set the whole thing transparent and in the paint event draw the background on it.
    declare function NSClassFromString lib "Cocoa" (aClassName as CFStringRef) as Ptr
    Declare Function colorWithCalibratedWhite Lib "AppKit" Selector "colorWithCalibratedWhite:alpha:" (NSColorClass As Ptr, white As Single, alpha As Single) As Ptr
    Declare Sub setBackgroundColor Lib "AppKit" Selector "setBackgroundColor:" (NSWindow As Ptr, backgroundColor As Ptr)
    Declare Sub setOpaque Lib "AppKit" Selector "setOpaque:" (NSWindow As Ptr, flag As Byte)
    setOpaque(Ptr(self.Handle), 0) // Zero for NO in Objective C
    setBackgroundColor(Ptr(self.Handle), colorWithCalibratedWhite(NSClassFromString("NSColor"), 1, 0))  

Thanks Bill !

In that link, it is not a window placed under the NSStatusItem, but instead an NSPopover shown at the status item’s view. As I said in the list of declares thread I am working on putting together an example which shows how to do this. A quick sample is here, but I will have better example in a few days.

Thanks Jason - is there a link to the required image :slight_smile:

Sorry about that.
https://www.dropbox.com/s/up97bq2yeppbe5v/applicationImage%20.tiff

Thanks for the example Jason :slight_smile:

That’s interesting…so a NSPopover is not an actual window.

When I import that into my own app - my 16 x 16 NSStatusItem increases in size and gets blurred.
Also, where is the code which causes the button to get added?

Thanks.

[quote=108891:@Kuzey Atici]Thanks for the example Jason :slight_smile:

That’s interesting… so a NSPopover is not an actual window.[/quote]
Correct

Not sure what you mean… maybe post a screen shot?

In the StatusItemView I added a method “MakePopoverView” which is where the button creation occurs. I plan to clean that part up and give access to the internal EasyPopover instead so that a special method does not need to be created in the StatusItemView class.

Ah, I had assumed the OP wanted to use a Xojo window instead of an official popover window, hence my transparency solution.

I’m happy to use anything :slight_smile:

Bill, what versions of OS X support this windows transparency?
Also, what is a figure shape?

Thanks.

From the LR:

You can see how I use it for my popovers (cross-platform) in this post:
Popovers (my solution)

I’ve modified the popover project a little (mostly to make it way faster on Windows) and haven’t updated it yet - I’ll need to get around to it soon. But the bulk of the FigureShape stuff is the same (I think).

Look in the GSPopoverWindow class at the “displayPopoverAt” method for the transparency calls. Look at “setWindowShape” for how I draw the FigureShape (it looks complicated because the pointer can change position both on which side and where on the side it goes), and then the Paint event for where the FigureShape gets drawn on.