| |
| | |

Apple Phoon Forum

 Forgot password?
 Register
View: 1668|Reply: 6

ApplescriptObjC NSPopover

[Copy link]

Post time: 2014-02-20 21:57:57 |Show all posts
AppleScript
Hi everyone,
I a writing an app in ApplescriptObjectiveC and I need some help with the NSPopover. I am trying to create a simple app that when the button is pressed shows a small popover, but I am having trouble with the code. After doing some research I got to this point
property thePopOver:missing value
on showPopOver_(sender)
set thePopOver to current application's NSPopover's alloc()'s init()
tell thePopOver
set ofView to sender
set showRelativeToRect to sender
set preferredEdge to NSMaxYEdge
end tell
end showPopOver_
The code compiles, the handler gets called correctly but it tells me that NSMaxYEdge is not defined. Can someone please help me??
        Applescript, OS X Mountain Lion (10.8.2)
Reply

Use magic Report

Post time: 2014-02-21 07:24:55 |Show all posts
In other examples the relative rectangle is set to the the bounds of the control, but I used the bounds of the window view so you could play with the poistioning by changing the view to other items (I added a couple of comments last night to the project I originally posted). It works either way, since the rectangle gets adjusted if it is out of bounds. Good luck.
Reply

Use magic Report

Post time: 2014-02-21 05:36:22 |Show all posts
Thank you for your help...After a bit of playing around I was able to get it to work just the way I wanted it
Reply

Use magic Report

Post time: 2014-02-21 04:28:28 |Show all posts
OK, I set up a simple example project that pops up a text view over the calling button. Nothing too fancy, although I did throw in a delegate method to show how to use those You can download it here.
Reply

Use magic Report

Post time: 2014-02-21 02:29:11 |Show all posts
Hi red_menace,
For the bindings I took it mostly from here: http://www.youtube.com/watch?v=P3uehLU67cg . but even with your modifications I can't get it to work...if possible could you please upload a sample project so that I can take a look on how to do it properly???
Thank you very much for your help
Reply

Use magic Report

Post time: 2014-02-21 00:46:54 |Show all posts
I just noticed that your variables look like parts of a method name, so I don't think you are on the right track here - what are you doing to connect up the popover to its view controller?
NSPopover's showRelativeToRect:ofView:preferredEdge: method converted to AppleScriptObjC would look like:
thePopOver's showRelativeToRect_ofView_preferredEdge_(positioningRect, positioningView, preferredEdge)
Reply

Use magic Report

Post time: 2014-02-20 23:30:59 |Show all posts
You also need to target the current application for framework constants, e.g.:
set preferredEdge to current application's NSMaxYEdge
Reply

Use magic Report

You have to log in before you can reply Login | Register

Archive| Apple Phoon

2021-04-18 06:44 GMT-8 , Processed in 0.070035 sec., 27 queries .

Powered by Discuz! 7.2

Release 20121101, © 2001-2021

To Top