Все вопросы: [nsview]
39 вопросов
Пользовательский NSStatusItem с настраиваемым представлением - использовать NSWindow, NSView, настраиваемый NSMenuItem?
Я пытаюсь создать приложение LSUIElement, которое ведет себя как Spotlight, CoverSutra и другие приложения этого типа.Мне удалось создать настраиваемый NSStatusItem, который вызывает всплывающее окно NSWindow, но проблема в том, что приложение, которое в настоящее время имеет фокус, будет фокуси...
Как отличить одиночный щелчок от двойного щелчка в Какао на Mac
У меня есть обычай NSView (это один из многих, и все они живут внутри NSCollectionView - я не думаю, что это актуально, но кто знает). Когда я нажимаю на представление, я хочу, чтобы он изменил состояние выбора (и соответственно перерисовал себя); когда я дважды щелкаю вид, я хочу, чтобы оно отк...
Затенение содержимого NSWindow
У меня NSWindow с 2 NSViews (NSSplitView и кастомный NSView).Доступ к данным для заполнения этих представлений может занять некоторое время.В этот период я хотел бы выделить серым цветом содержание этих просмотров. Мой первый подход заключался в том, чтобы получить одну черную третью NSView, к...
Изменить размер представления NSCollectionViewItem
Как программно установить размер представления NSCollectionViewItem? Я пробовал сделать это в подклассе NSCollectionView: @implementation CustomCollectionView - (NSCollectionViewItem *)newItemForRepresentedObject:(id)object { NSCollectionViewItem *newitem = [[self itemPrototype] copy...
Why is bitmapImageRepForCachingDisplayInRect: creating an empty image?
I have a very simple bit of code that is supposed to capture the bitmap of a view. This used to work in Leopard, but seems horribly broken in Snow Leopard. Here is the code, responding to a button press on the window: - (IBAction)snapshot:(id)sender { NSView* view = [[sender window] conten...
Making NSScroller larger
I'm making a Cocoa application optimized for external touch sensitive screens, so I want to make a large scollbar in an NSScrollView. I've tried just to resize the scrollers frame, but both drawing and mouse events only happens in the scroll area, it doesn't get wider (it's the vertical scroller)...
Handling messages to the first responder in a view controller
I must be missing something simple, but I can't see it. First, the setup: DATreeView, a subclass of NSView DATreeViewController, a subclass of NSViewController MainMenu.xib has an instance of DATreeViewController, which is configured to load a view from DATreeView.xib MainMenu.xib also has an ...
mouse click events in an NSView subclass
I have an NSView subclass that gets initialized with an OpenGL context and has a bunch of mouse event handling (onMouseDown, etc...). I have an app using it which has a main Cocoa window that contains the view and all the mouse events are working properly. However, I'm trying to use it now in an...
Dimming NSWindow and layer NSView on top
Is there any way I could dim my NSWindow (basically putting a black transparent layer over top of it that you cannot click through) and then layer a custom NSView on top?
drawRect not being called on added subview
I'm trying to programmatically create a window with custom contentView and one custom NSTextField control, but i'm having trouble getting this hierarchy of window and views to draw themselves. I create a custom borderless window and override it's setContentView / contentView accessors. This seem...
NSMatrix and autoresize only certain cells?
I have an NSMatrix with two columns, When the frame resizes I don't want the left column to resize with it. Is there a way to do this without subclassing NSMatrix? I am thinking maybe I should just make two NSMatrix's and position them side-by-side, one with autoresizing set to YES and one set...
How to Rotate a CALayer-backed NSView subclass
I have a custom NSView subclass that I want to animate with Core Animation. I am already (without CA) setting the position and rotation of these views with NSView's setFrameOrigin and setFrameRotation methods. However, no matter what I do, once I add a layer backing to the views I can't get them ...
NSView leaves artifacts on another NSView when the first is moved across the second
I have an NSView subclass that can be dragged around in its superview. I move the views by calling NSView's setFrameOrigin and setFrameRotation methods in my mouseDragged event handler. The views are both moved and rotated with each call. I have multiple instances of these views contained by a s...
How do I make an NSView move to the front of all NSViews
How do I make an NSView window move up to the front. My app has 3 windows and when I press a button in one of them I want another to move on top of this one.
Drawing an image in a NSView
I have a simple Obj C program that, at the moment, lets you load an image, draws it up, and theoretically should let you zoom and rotate. I'm using NSAffineTranslations. I want the image to be locked to the upper left (As opposed to the PS/PDF standard of lower left), so I'm using isFlipped, and...
How do I fix the height of my view after collapsing NSSplitView?
I've got an NSSplitView with an NSScrollView in the bottom view. The problem is when I collapse, and then re-open (un-collapse) the bottom view, the height of the scroll view is beyond the height of that bottom view so the top part of the scoll view is being clipped. I've got my scroll view and...
NSColorWell subclass not getting mouseMoved events
I'm trying to implement a color picker in my Cocoa app. (Yes, I know about NSColorPanel. I don't like it very much. The point of rolling my own is that I think I can do better.) Here's a picture of the current state of my picker. (source: ryanballantyne.name) The wells surrounding the color...
Why shouldn't I use a cursor rect on a rotated NSView subclass?
I am writing a custom NSView subclass. I have several instances of this class in my window, most of which are rotated by calling NSView's setFrameRotation method. I also need to change the cursor when over a rectangular region of this view. The documentation for NSView's addCursorRect method con...
How to implement very large scrolled view in Cocoa
Is it wise to create views in Cocoa that have dimensions around 15000 pixels? (of course only small part of this view will be visible at a time in a NSScrollView) Interface Builder has limit of 10000 pixels in size. Is this an artificial limitation or is there a good reason behind it? Should I ...
Better way to move NSView bounds with player?
Currently writing a roguelike to learn more about Objective-C/Cocoa. I'm really enjoying it so far and I've learned tons. This code moves the origin of the view's bounds, so that it follows the player as he moves. The code works perfect, I was just asking if there was a better way than using fo...
What's the RIGHT way to draw an image in the upper left corner on a mac?
I have an NSView in a ScrollView and I'm trying to draw an image in it. The problem is that I want the upper left corner of the image locked to the upper left corner of the frame, instead of the lower left corner, which is what the View wants me to do. I will need to be able to zoom in and out, a...
In Cocoa, what is the best way to change the cursor when hovering over a circular view?
What I want to do I have a circular custom NSView subclass, and I want to change the appearance of the cursor when the mouse is hovering over the circular portions of the view, but not when over the portions of the view's rectangle that fall outside the circle. Here's an illustration. I would h...
Obtain a CGContextRef of NSView outside of drawRect?
I need to get CGContextRef of NSView object. It won't be so bad if I knew how. In Carbon this thing was done like this: CGContextRef cgref = (libvlc_drawable_t)GetWindowPort(HIViewGetWindow((OpaqueControlRef*)hiViewRef)); Obviously it can be done by subclassing NSView (or it's subclass) and c...
Why does an NSView's frame method return the wrong results?
I occasionally want to change an NSView's dimensions programmaticaly. To do this, it is helpful to get the dimensions of various views, adjust them relative to each other, and then use setFrame: to reposition. The problem is that the frame method usually returns NSRects that are clearly wrong, ...
NSAffineTransforms не используется?
У меня есть подкласс NSView, и в нем я рисую NSImage. Я не использую NSAffineTransforms для поворота, перевода и масштабирования изображения. Большинство из них работает нормально. Однако иногда кажется, что преобразования просто не активируются. Например, когда я изменяю размер окна, прео...
Динамическая загрузка части окна в какао
У меня есть область окна (в моем MainMenu.xib), которую я хотел бы динамически заполнять несвязанными "представлениями", такими как NSTable, IKImageBrowserView и т. д., в разные моменты времени в зависимости от некоторых выбранных пользователем критериев. . Как определить эту область окна та...
Почему подпредставления NSView не отправляют сообщение о выпуске при завершении работы приложения Какао?
Краткая версия: Почему подвиды объектов NSView не отправляют сообщение release при завершении работы приложения Какао? Есть ли способ изменить это поведение? Пример: Показанный ниже класс MyView - это не что иное, как подкласс NSView, который сообщает консоли, когда он создается и...
Определение того, какой экземпляр NSView инициировал mouseDown:
У меня есть игровая доска с 25 плитками myGameTile, подкласса NSView. В mouseDown: я хочу определить, на какой плитке я щелкнул, и установить для ivar репрезентативное значение. например Если я нажму на плитку 12, установите для clickedTile значение «12» или какое-либо значение, которое уника...
Поведение автоматического изменения размера NSView
Мне нужно понять, как NSView автоматически изменяет размер представлений. Я настроил все в IB, и мои подпредставления красиво меняют размер (когда я изменяю размер своего окна с помощью мыши). Однако, если я сделаю [myMainView setFrame:] с новым прямоугольником кадра, ничего не произойдет. Все м...
Как отобразить неархивированные пользовательские объекты NSView
Я изучаю программирование на Cocoa и не могу понять, как архивировать и разархивировать настраиваемый подкласс NSView Я сделал игрушечное приложение с окном. Это окно содержит экземпляр моего настраиваемого класса BackgroundView (заархивированный в файл xib). Щелчок в любом месте этого Backgr...