MacGapProject / MacGap1

Desktop WebKit wrapper for HTML/CSS/JS applications.
Other
3.55k stars 208 forks source link

Input fields not accepting keyboard events #131

Open brycecammo opened 10 years ago

brycecammo commented 10 years ago

I'm having some trouble with my MacGap application, and no amount of Googling has been able to solve it. The problem is I cannot type inside the web view. I can focus on HTML <input/> fields and click buttons, etc, but when trying to type it just makes that ‘doh’ sound & no text is entered into the field. I'm using XCode v 5.1.1 on 10.9.

I've added an NSToolbar above the main WebView window if it makes any difference.

When comparing my application to a fresh MacGap app (which works fine) I can't identify anything different that may be causing the issue.

Any ideas on where I should be looking to identify the problem would be greatly appreciated.

rawcreative commented 10 years ago

It's likely an issue with the toolbar, the first thing that comes to mind is that either the webview or toolbar are overlapping each other in IB which can sometimes cause issues like that because one is intercepting the events meant for another. If you've changed other code under the hood, then it's almost impossible to give you a helpful answer without seeing what has changed or what you've implemented. If you can post a link to the project repo I can take a look if you'd like.

brycecammo commented 10 years ago

Hmm, so this is embarrassing. Your comment made me take another look at the project in interface builder to see if there was some sort of stacking/overlapping issue, but nothing came up. Then I decided to open a fresh MacGap app and copy everything over one-by-one to see if I could isolate the issue (which I've already tried several times). Turns out in my CSS I had the following:

* {
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    cursor: default;
}

That -webkit-user-select is to make it so you can't select any text in the interface, but it also disables typing in input fields. Doh! The amount of time I've wasted thinking it was some obscure issue with my Obj-C code...

@rawcreative - thanks for offering to help anyway - much appreciated.

jeff-h commented 10 years ago

@brycecammo — any chance you'd be willing to do a quick write-up in the wiki on how to implement an NSToolbar in MacGap? Even just the fundamentals and a few screenshots would do the trick. I've been meaning to do this but haven't had a chance as yet. Did you use the User Defaults to provide communication between the toolbar items and JavaScript?

brycecammo commented 10 years ago

@jeff-h – I'd be happy to. I needed to send some other information from the native code to Javascript, so I used https://github.com/marcuswestin/WebViewJavascriptBridge to send toolbar events to the app.

perfaram commented 10 years ago

By the way, this could be an interesting thing for MacGap2. I don't know how toolbar works with Cocoa, but I guess that they can be registered after the window is drawn (not like this). And we could have something like macgap.toolbar.create, and macgap.toolbar.additem, and so on... MacGap has a bright future !

jeff-h commented 10 years ago

I'd really like to get a page on implementing your own toolbar into the MG2 docs. I feel like it would be silly to try to programmatically create a toolbar from inside MG2, since Interface Builder already provides a very comprehensive UI for creating everything imaginable in a toolbar. I think connecting everything together is where it gets tricky.