NSPopover basic questions

Hi there,

I just don’t get it… ahhhhhhhhh… :mad:
So I just wanted to play around and try to make a popover with 2 textfields that get their text from the code.


script AppDelegate
	property parent : class "NSObject"
    
    property myLBL01 : missing value -- connected via IB to Label 1
    property myLBL02 : missing value -- connected via IB to Label 2
    
    property popoverWindow : missing value --connected via IB to PopoverViewController
    -- in IB I have a HUD window that contains the 2 Labels and is connected to the PopoverViewController
    
	on applicationWillFinishLaunching_(aNotification)
		-- Insert code here to initialize your application before any files are opened 
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits 
		return current application's NSTerminateNow
	end applicationShouldTerminate_
    
    on openPop_(sender) -- connected via IB to a button
       myLBL01's setStringValue_("Text01")
       myLBL02's setStringValue_("Text02")
       popoverWindow's showRelativeToRect_ofView_preferredEdge_(sender's |bounds|(),sender,2)
    end openPop_
	
end script

What am I doing wrong?
Also: where would I adjust properties for the popover like “animates”?

Thanks in advance.

Cheers,
Chris

Hi,

showRelativeToRect:ofView:preferredEdge: is a method of NSPopover.
Connect the NSPopover object to a property in your script.
In this class you can specify appearance and animation

I recommend to use a separate xib and custom subclass for the view controller.

Thanks - of cause, I found the animate property in IB.
The code was corrects - I forgot to connect the view to the popver and set the nib in the propover.

One more thing though:
If I would want the Popover to disapear if I just click somewhere… where do I need put the code?

Set the behavior of the popover to NSPopoverBehaviorTransient or NSPopoverBehaviorSemitransient

You should look up the documentation for NSPopOver. There is a method named behavior that can help you achieve what you want.

Thanks guys. Really: I didn’t quiet get the documentation on this …
But even worse: also the behaviour is just a setting you can pic in IB.

Thanks again! :slight_smile: