I'm working on embedding a WebView in Cocoa. I have the basic view up and running, but the problem I'm facing is when I type using either the keyboard or the on-screen keyboard, I get a beep from my Mac and none of the characters are actually shown in the Web view's text field.
I've been going through the web view's reference guide from Apple, but couldn't find anything related to this.
Any help is much appreciated!
Thanks,
Teja.
Omz's comment solved the issue for me. I changed my NSWindow styleMask to a style that can become a key window:
window.styleMask = NSTitledWindowMask
Related
I want to write a MacOS Cocoa Desktop App with XCode 10 and Swift 4.2.
It should have a searchfield with a suggestions view opening as you keep typing like Google Search or Spotlight with autocompletion.
However I'm completely new to Cocoa programming.
I have already tried to add an NSSearchField and a dynamically added NSPopOver object with subclass of NSTableView which contains all the suggestions. But I am not happy with the suggestions view because of the anchor/arrow that appears with it. It seems like it breaks the UI guidelines.
Thus I have tried to implement my own custom subclass of NSView containing the suggestions. It works fine but I struggle with simple things like making it hide/disappear as soon as any other area is clicked in the app.
Does anyone know a good example as best practice for this task or have some sample code?
I have been making iOS apps for a while now and I decided that I wanted to start working on making some of them for the Mac too.
The question I have is this: is there any need for an NSWindow, now that developing for the Mac is so similar to iOS??
So I made a simple cocoa application using Xcode and its comes with a storyboard called "Main", just like on iOS.
In that storyboard file, there is a NSWindow which then links to a NSViewController.
Can I get rid of that NSWindow? As I tried setting the NSViewController as the "Initial Controller" and the app still works fine. So whats the point of the NSWindow?
Also, what class links to the NSWindow? I was trying to blur that background of the NSWindow, but I have no way of linking code to the NSWindow.
Sorry for my stupid questions, but I am completely new to development for OS X.
Thanks for your time, Dan.
Those are many questions in one question:
Can I get rid of NSwindow? No, you need a window to show you views.
What is the point of the NSWindow? NSWindow is needed as the window in which the views are displayed and your events are going up the responder chain.
What class is linked to NSWindow? Obviously the NSWindow class, but that is not what you want to know. I think you want to know the delegate that controls NSWindow. This is NSWindowController, although for the MainMenu.xib it is NSAppDelegate.
Hope this gives you the answers you need. An example for working with views in a window is given in this question.
Please, see for further details the windows programming guide, which states:
The NSWindow class defines objects that manage and coordinate the
windows an application displays on the screen. A single NSWindow
object corresponds to at most one onscreen window. The two principal
functions of an NSWindow object are to provide an area in which NSView
objects can be placed and to accept and distribute, to the appropriate
views, events the user instigates through actions with the mouse and
keyboard.
For the question: Can I get rid of NSwindow? I have further comments. In most cases, You need a NSWindow to show view on screen; but in special case you don't, for example, a popup view when you click a NSStatusItem.
So my answer is whenever you need to respond window event such as min/max, you need NSWindow as the view container.
I have added textfield (keyboardTextField) and UISwitch on top of my custom keyboard. I can set focus ON or OFF for (keyboardTextField) on the base of Switch value my code.
- (void)switchToggled:(id)sender
{
UISwitch *mySwitch = (UISwitch *)sender;
if ([mySwitch isOn])
{
[keyboardTextField becomeFirstResponder];
}
else
{
[keyboardTextField resignFirstResponder];
}
}
So whats happening right now at first time when my custom keyboard launch its working in each app of my device,But it's impossible for me to select the input view of the main app back after changing Switch value to On and then OFF and now my custom keyboard can't write any thing in any app of my device.
This type of questions already has been asked here and here but no one answered yet. If someone have any workaround or any ideas, Please share.
I'm making an extension keyboard for IOS and have same problem like you. My purpose is to add an UISearchBar to keyboard like this app but I could not find an answer in any forum where I posted this question.
I even asked Apple Technical support but they answered that this is a bug of iOS keyboard extension.
Last day I found an app is Kanvas keyboard and I think a have my solution, and that's use an UILabel instead UITextField or UISearch in the extension.
That will keep my app work fine. Hope this can help you.
How could I make an NSWindow's title bar look like that of the Mac App Store or of the app Feeder where it's height is increased and other controls are show in it.
To see what I mean just check out the website for the Mac App Store : http://www.apple.com/mac/app-store/.
Is it a custom NSWindow or is it a completely borderless window with an NSView made to look like the title bar?
https://github.com/indragiek/INAppStoreWindow
Title bar and traffic light customization for NSWindow
INAppStoreWindow is an NSWindow subclass that was originally developed to mimic the appearance of the main window in the Mac App Store application introduced in OS X 10.6.6.
The MAS application has since transitioned away from this design, but INAppStoreWindow is still being actively developed to provide extensive additional customization options for NSWindow title bars...
For iTunes (v9.x) Apple used no toolbar, but custom aligned icons and controls in the top bar, to achieve a similar effect. (see link below)
The window looks like a "textured & unified title and toolbar" window to me. (or a slight variant of such)
To reposition the traffic light buttons follow my answer to this question.
However, as Dave DeLong already (similarly) commented: "The UI is terrible. Please don't even think about it."
You can also take a look at http://orestis.gr/blog/2007/09/24/messing-with-windows/ . This uses some undocumented stuff, though, so it won't actually get approved FOR the App Store.
Hey all, quick question that has been bugging me about NSPanel. I like the look of The NSPanel HUD but for the project I am doing I need the Panel to not be moved. Does anyone know of any possible solutions to make it were my NSPanel cannot be moved at all but maintain its buttons interactivity? I've been searching for any questions similar to this for awhile now. Any insight on the issue would be helpful! Thanks.
Don't forget to look in superclasses. A panel is a kind of window, and since Mac OS X 10.6, it's possible to set a window's movable property to NO.
I'm with Dave DeLong, though: I hope you have a good reason to break this functionality. Users expect to be able to move windows, especially those with title bars and HUD windows by their backgrounds, out of their way. And remember, you're not the only application on the system; the user may have something important to get to in a window in another application.