Thursday, December 14, 2017

#1 2016-03-19 11:48:20 am

mac.jedi
Member
Registered: 2008-04-23
Posts: 43

detachableWindowForPopover

I've been struggling to get a popover to detach to a window.  Any tips?

Thanks so much!!!

Applescript:



script AppDelegate
   property parent : class "NSObject"
   
   -- IBOutlets
   property theWindow : missing value
property popOver : missing value
property popoverTriggerButton : missing value
property popoverWindow : missing value

   on applicationWillFinishLaunching_(aNotification)
       -- Insert code here to initialize your application before any files are opened
popOver's popoverShouldDetach:true
popOver's detachableWindowForPopover:popoverWindow
   end applicationWillFinishLaunching_
   
on togglePopover:sender
if sender's state() is 1 then
popOver's showRelativeToRect:(sender's |bounds|()) ofView:sender preferredEdge:(current application's NSMinYEdge)
else
popOver's performClose:sender
end if
end togglePopover:

   on applicationShouldTerminate_(sender)
       -- Insert code here to do any housekeeping before your application quits
       return current application's NSTerminateNow
   end applicationShouldTerminate_
   
end script

Offline

 

#2 2016-03-20 11:37:19 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: detachableWindowForPopover

By the look of things you need to declare a delegate of your popover, and in that have a -detachableWindowForPopover: method. When this is called, it should return a window, and the popover will then animate to appear as though it morphs into the window. IOW, there's a fair amount of work involved.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2016-03-21 12:21:37 am

mac.jedi
Member
Registered: 2008-04-23
Posts: 43

Re: detachableWindowForPopover

Shane Stanley wrote:

By the look of things you need to declare a delegate of your popover, and in that have a -detachableWindowForPopover: method. When this is called, it should return a window, and the popover will then animate to appear as though it morphs into the window. IOW, there's a fair amount of work involved.


Thanks for the reply!!!  Earlier today, after a lot of trial & error, I finally got it to work and it looks so simple … I guess I didn't quite grasp how the delegate method worked. 

I had to connect the app delegate to be the delegate for the popover, and set a function for the popoverShouldDetatch method, returning true.  Then just call the function in the finished launching function. 

I need to brush up on your teachings.

Thanks again!!!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)