Deactivate Application on MacOS

Hi,

I would need to deactivate my Xojo application to give the focus to the next application in line.
I have tried the following declare but, although I do not get any bug, nothing happens.

  Method DoNotBringAppToTop

  declare function NSClassFromString lib "Cocoa" ( inName as CFStringRef ) as Ptr
  declare function sharedApplication lib "Cocoa" selector "sharedApplication" ( classRef as Ptr ) as Ptr
  Dim myApp as Ptr =  sharedApplication( NSClassFromString( "NSApplication" ) )
  
  declare sub DeactivateMe lib "Cocoa" selector "deactivate" ( appRef as Ptr )
  DeactivateMe myApp

Any clues about why this is not working ?

thanks,
Happy Holidays,
Franck

you send your app a notification that it was deactivated? Doesn’t make sense.

You could try:

  • (void)hide:(id)sender
    followed immediately by:
  • (void)unhideWithoutActivation

Christian :
Yes, I have an application that is floating on top of the other ones. When the ouse quits its window, even if the user is not clicking anywhere, I need the focus to leave my application and to to the one underneath.

Eli:
yes, this is what I am doing. It has the tendency to flicker a bit so I wanted to see why the direct way was not not working as it should.