I need to develop a chat window kind of view, with the following requirements:
Be able to display an image
have custom control like a progress bar
scrollable, and finally,
copy and paste
I want to know which class should I use. Can I achieved all the above using NSTextView or should I go with a NSView and keep ScrollView inside it (drawing the text and other custom controls manually)
I appreciate your valuable comment
Thanks in advance
Just drag a nstextfield in your window in the interface builder. It will be much easier
Related
Simple question, starting out with macOS stuff – I’d like to create a small radial menu around my cursor, top-most, above whatever application is currently active, whenever a specific mouse button is pressed.
I have the specific mouse button over all application down, but I’m wondering where I need to draw that NSView, i.e. “topmost”. I guess on iOS this would be at the UIWindow level, but would NSWindow be the wrong approach here?
this is purely an opinion-based question, but basically if you want to present any custom content on the desktop, that should use NSWindow, and you can customise the window's content for your wish.
NOTE: you can find more information about the NSWindow class in Apple's Class Reference Docs.
I have a simple question. I have my NSView which is detecting drops (drag and drop). When user drops a link with image from browser, I detect that action, create NSImageView, initialize it on a place where user dropped it with some default frameSize and put the image from the link into it.
I would now like to highlight that NSImageView when user clicks on it. I also want to implement moving around that NSImageView in NSView but I'm pretty sure I will manage that. How do I highlight that exact NSImageView which was clicked? I haven't created earlier that NSImageView in interfacebuilder and assigned a special class for it so I can use drawRect, I have just created it dynamically...
Any help would be appreciated.
You can use NSImageView's setImageFrameStyle for highlighting.
Is there a bevel style that can replicate NSToolbar style of buttons that are used, for instance, in the Safari's preferences window to switch between different panes?
I need to replicate NSToolbar in an NSView using NSButtons. I understand that I should probably be using NSTabView, but I'd like to implement the look of xcode's left pane. Any tips here would be appreciated greatly.
There's nothing built-in, you'd have to create the images yourself. However, replicating the behaviour is straightforward.
You could simply use a single-row NSMatrix of NSButton objects. Just give the buttons an image and an alternate image (for the highlighted state) and set the matrix mode to NSRadioModeMatrix.
I am trying to write an app. that will allow the user to drag from an NSButton to another. When dropped I would like the Title to be dropped onto the button.
I cannot find a way to make NSButton draggable. Is it possible?
First a warning: this sounds like it would be confusing to a user. Buttons are intended to emulate buttons in the real world. You push them rather than drag them around.
Having said that, it's certainly possible to do in a subclass of NSButton.
Drag source
Implement the dragging source method draggingSourceOperationMaskForLocal:. Sounds like you're copying the title, so you may want to use NSDragOperationCopy.
Call dragImage:at:offset:event:pasteboard:source:slideBack: in your mouseDragged: method. Use the drag pBoard ([NSPasteboard pasteboardWithName:NSDragPboard]) and copy your button title into it. For the image you can draw your button into an NSImage and use that as the drag image, or you might use an icon or even just the title.
Drag destination
Register your custom button to be able to accept the title string using registerForDraggedTypes:.
Implement the drag destination methods draggingEntered: and performDragOperation: to return appropriate values. There are several other methods including draggingUpdated: and draggingExited: among others that you can use to provide visual feedback.
There's lots of info out there on implementing drag & drop. Read Apple's docs: Drag & Drop Programming Topics and Pasteboard Programming Guide
I'm creating an application, from which a part looks like this:
boo http://img188.imageshack.us/img188/7808/schermafbeelding2010021y.png
I all dragged them to a window in IB, but the problem is that the NSImageView, Action Buttons (Suggest, Send, Poke etc...), Information NSBox, and Friends NSTabView can all vary in height. They should always be placed below each other, with a margin of 8px. Just like on Facebook. I thought of a very modified NSSplitView, but maybe there are easier ways. Can anyone help me out?
Edit: I have placed the action buttons in a Custom View with class NSView.
Thanks
You'll have to manually resize the views yourself. Cocoa does not provide Java-style LayoutManagers. However, I don't think it would be too hard to recreate one...