Color picker opens when I run my app

I was playing around with the system color picker in a test app, and something must have gotten messed up because now whenever I run an app with the default application ID Xojo gives me, the color picker opens automatically (debug and built). Even if it’s just a new, empty desktop app (Xojo 2019-2021).

If I change the application ID, the problem is fixed. But if I change it back, the problem comes back.

Any ideas where this issue is coming from? I tried deleting the Xojo cache and the cache for that application id, but it didn’t change anything.

this is apples app restore in effect
it reopens windows that were open when you quit the app

let me dig up some code to check for it and then in you close it and no issue

add this method somewhere and call it in the event

Sub CloseNSColorPanel
  #If TargetMacOS Then
    Declare Function NSClassFromString Lib "AppKit" ( className As CFStringRef ) As ptr
    Declare Function sharedColorPanel Lib "AppKit" selector "sharedColorPanel" ( classRef As Ptr ) As Ptr
    Declare Sub close Lib "AppKit" selector "close" ( panel As Ptr )
    close( sharedColorPanel( NSClassFromString( "NSColorPanel" ) ) ) 
end sub

that should do it

Thanks - that code does close it, but it still shows up for a second, then fades out. It would be nice to figure out why Apple decided I wanted it to be reopened every time, and get it fixed at the source instead. :slight_smile: At least I can keep this code in my toolbox as a backup plan.

or put it in app.close and make sure its close before your app quits :slight_smile:

because they know better than you do what you want ?
app restoration tracks all open windows and the next time your app opens it reopens them
there may be a plist key to opt out of that
never really looked for that

It’s for sure closed when my app quits (it opens in empty/new apps as well, which certainly don’t have it open), although apparently at one point it wasn’t. Somewhere it got tagged in the OS as needing to be open for that app id, and there’s no place I can find to untag it.

Ah, found it. In “~/Library/Saved Application State” I deleted the “com.[me].myapp.savedState” folder and it seems to have fixed it.

There is a defaults key you can set in the application that will disable Resume for that application. I’m not at my ‘work’ puter right now, but I’ll try to remember to dig it out for you. It is undocumented by Apple and I don’t recall how I found it, maybe from spelunking UserDefaults…

1 Like


NSUserDefaultsSetBoolForKey( NSUserDefaultsStandard, True, "ApplePersistenceIgnoreState" )

I have to confess that I am uncertain if this still works in recent versions of the macOS, the lack of documentation doesn’t inspire confidence either.

LOL, thanks for the info though.

Control Panel → General

search a checkbox:

Thanks, I’d already tried that and it didn’t fix anything. I had to delete the folder manually.