问题标签 [nspoint]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
510 浏览

objective-c - How to read point coordinates from a file with Objective-C?

I have a file like this:

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 NSPoint.

BTW, I tried to write Objective-C++, but it seems that ifstream does not work, which is a bug of XCode.

0 投票
1 回答
320 浏览

objective-c - 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 to get coordinates of pixel in a bitmap. So I've ovveride mouseDown: method:

After getting NSPoint I should try to convert it to co-ordinates of a bitmap BUT first I have no idea How to solve the problem that locationInWindow returns NSPoint of a NSImageView, not of the bitmap which is ussually smaller and has unused margins in NSImageView, but I can click on the margin and mouseDown event returns me NSPoint in that margin. Do you have any idea what I shoud do?

0 投票
1 回答
1333 浏览

uiview - NSPoint、CGPoint、NSSize、CGSize和NSRect、CGRect的单位是什么?

CGPoint、CGSize 和 CGRect 的单位是什么;NSSize、NSPoint 和 NSRect?

0 投票
1 回答
6560 浏览

objective-c - 在当前屏幕中设置 NSWindow 位置

我是 Objective-c 的新手,我创建了一个主窗口,我想在当前屏幕的右下角显示它。我尝试了以下代码

它有什么问题?如何解决?

0 投票
1 回答
642 浏览

objective-c - 找到另一个 NSPoint 最接近哪个 NSPoint 的最佳方法是什么?

我有 4 个 NSPoint,它们是矩形的 4 个角

现在我有另一个 NSPoint,这是鼠标下降的地方(mousedown_nsp)。

找到与mousedown_nsp相关的最近的 NSPoint(在 4 个矩形角 NSPoints 中)的最佳方法是什么?

我想只是做一个比较来找到mousedown_nsp和其他 4 个 NSPoints 之间的距离,然后选择最小的距离,但我觉得必须有更好的方法。

有任何想法吗?

提前致谢!

0 投票
1 回答
711 浏览

macos - 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.

I'm using above code to do my conversion, but I get same coordinates for pnt.x and pnt.y no matter where mouse location is.

I noticed that this method is deprecated, but it should still work I guess, right?

Does anyone have any good suggestion on how I can do this conversion?

Any kind of help is highly appreciated!

0 投票
4 回答
3587 浏览

ios - Converting NSpoint and passing the values in to CGRectMake

I am getting a point in NSPoint as:

I want to pass 273 and 534 into CGrectMake.
For example:

I am not able to get the values in that NSpoint.
I tried passing it to NsArray and NSDictionary. Nothing works. Pls help

I use Po command in console and found the value which i need is in NSPoint. But dont know how to convert it

0 投票
4 回答
1379 浏览

macos - 鉴于单击鼠标,计算点的正确方法是什么

我的应用程序中有一个 NSView 的自定义子类。我想知道视图中的确切点,相对于它的原点,是用鼠标单击的。(即不是相对于窗口原点,而是相对于自定义视图原点)。

我一直使用这个,效果很好:

但是现在我收到一个警告说convertScreenToBase已被弃用,而是使用convertRectFromScreen。但是我不能从 convertRectFromScreen 得到相同的结果,而且无论如何,我对一个点感兴趣,而不是一个矩形!

我应该使用什么来正确替换上面不推荐使用的代码?提前致谢!

0 投票
1 回答
299 浏览

swift - 证明光标位置是否在 NSButton 的框架内

我有一个自定义NSButton类,想检查(在viewWillDraw)用户当前的鼠标位置是否在按钮框架内。

我使用 获得鼠标位置NSEvent.mouseLocation(),但这给了我相对于屏幕本身的绝对值 NSPoint

self.frame(= NSButton.frame) 而是返回一些相对坐标,指的是按钮超级视图。

结果,self.frame.contains(NSEvent.mouseLocation())不起作用,我不知道如何解决!

感谢任何帮助!

0 投票
1 回答
100 浏览

objective-c - 如何从 NSView 获取每个 NSPoint,NSWindow 上的子视图?

我有 mac 应用程序,我想显示来自特定 nspoint 的工作表,我有多个具有层次结构的视图,所以,我想在(上层视图,即太阳视图的子视图)视图上选择 nspoint,在 nswindow 中获取它并从中获取工作表目标点 c. 如何做到这一点?