Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input fields not accepting keyboard events #131

Open
brycecammo opened this issue Jun 7, 2014 · 6 comments
Open

Input fields not accepting keyboard events #131

brycecammo opened this issue Jun 7, 2014 · 6 comments

Comments

@brycecammo
Copy link

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

jeff-h commented Jun 8, 2014

@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?

@jeff-h jeff-h reopened this Jun 8, 2014
@brycecammo
Copy link
Author

@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
Copy link

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
Copy link
Member

jeff-h commented Jun 20, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants