Questions tagged [nspoint]
12 questions
5
votes
4 answers
Whats the correct way to calculate point in view that mouse was clicked
I have a custom subclass of NSView in my app.
I would like to know the exact point in the view, relative to it's origin, that was clicked with the mouse. (i.e. Not relative to the Window origin, but relative to the custom-view origin).
I have always…

Kenny
- 1,083
- 2
- 8
- 23
5
votes
4 answers
Converting NSpoint and passing the values in to CGRectMake
I am getting a point in NSPoint as:
NSPoint: {273,534}
I want to pass 273 and 534 into CGrectMake.
For example:
viewTwo.frame=CGRectMake(273,534,someValue,someValue)
I am not able to get the values in that NSpoint.
I tried passing it to NsArray…

iworld
- 345
- 1
- 4
- 17
5
votes
1 answer
Setting NSWindow position in current screen
I am newbie in objective-c.I have created a main window which I want to display in the right bottom of the current screen. I tried the following code
- (void)windowDidLoad
{
NSPoint pos;
pos.x = [[NSScreen mainScreen]…

boopathy
- 427
- 2
- 9
- 20
3
votes
1 answer
What is the unit of NSPoint, CGPoint, NSSize, CGSize and NSRect, CGRect?
What is the unit of CGPoint, CGSize and CGRect ; NSSize, NSPoint and NSRect?

Colas
- 3,473
- 4
- 29
- 68
2
votes
2 answers
Converting NSPoint to CGPoint using NSPointToCGPoint
How difficult can it be to access x and y coordinates from NSPoint...Can't believe it.
I get an NSPoint from following call:
var mouseLoc = [NSEvent .mouseLocation]
I need to access x and y coordinates. NSPoint does not offer a getter like CGPoint.…

user688262
- 171
- 11
1
vote
1 answer
Prove if cursors location is within NSButton’s frame
I have a custom NSButton class and want to check (within viewWillDraw) if the users current mouse location is inside the buttons frame.
I get the mouse position using NSEvent.mouseLocation(), but that gives me an absolute NSPoint in relation to the…

ixany
- 5,433
- 9
- 41
- 65
1
vote
1 answer
What is the best way to find which NSPoint another NSPoint is closest to?
I have 4 NSPoints, which are 4 corners of a rectangle
Now I have another NSPoint, which is where the mouse goes down (mousedown_nsp).
What is the best way for me to find the closest NSPoint (out of the 4 rectangle corner NSPoints) in relation to…

A O
- 5,516
- 3
- 33
- 68
0
votes
1 answer
Convert screen coordinate to window coordinate in Cocoa?
I've seen this question asked multiple times here, and I tried some answers, but it doesn't seem to work for me.
NSPoint pnt = [[self window] convertScreenToBase:[NSEvent mouseLocation]];
I'm using above code to do my conversion, but I get same…

Eugene Gordin
- 4,047
- 3
- 47
- 80
0
votes
1 answer
Getting co-ordinates of bitmap on mouseDown in NSImageView
I am working on an app where I display unsupported (by XCode) file format). So I've subclassed NSBitmapImageRep to display it in a subclass of NSImaageView. I've set it up to be proportionally scallable (up or down). Now I need to add a possibility…

zioolek
- 421
- 5
- 15
0
votes
1 answer
How to read point coordinates from a file with Objective-C?
I have a file like this:
1.0 1.0
2.0 2.0
-3.0 2.0
each line is the coordinate of a point.
I don't know how to write a code to do following thing: read these coordinates from the file, convert them into double and store them in an array as…

HanXu
- 5,507
- 6
- 52
- 76
-1
votes
1 answer
How to return an undefined value for NSPoint
I am learning swift and I am trying to make a simple app where I move an object (The default ship) with the keyboard. I am designing an event to represent the left keypress. Since I do not need the mouse to be at a specific place, NSLocation is of…

Louis Couture
- 72
- 1
- 9
-2
votes
1 answer
How to get each NSPoint from NSView, subview on NSWindow?
I have mac application, I want to display sheet from particular nspoint, I have multiple views with hierarchy, So, I want selected nspoint on (upper level view i.e. sub view of sun view)view, get it in nswindow & present sheet from that point in…

user3581597
- 11
- 8