Skip to main content

JDIC not responding to keyboard input in forms when using webkit browser

15 replies [Last post]
sairam71
Offline
Joined: 2007-04-17

There is a thread similar to what I am experiencing, but it has no resolution. http://forums.java.net/jive/message.jspa?messageID=247011#247011

The problem I am running into is that on OS X, I have the following code to invoke the browser,

BrowserEngineManager bem = BrowserEngineManager.instance();
bem.setActiveEngine(BrowserEngineManager.WEBKIT);
webBrowser = bem.getActiveEngine().getWebBrowser();
webBrowser.setURL(new URL("http://www.google.com"));

This is a slight modification of the example code in Browser.java. When it displays google.com, I cannot input anything into the google search field.

I try this on windows with, bem.setActiveEngine(BrowserEngineManager.IE); and everything works fine.

Any help is appreciated on how I can get the webkit browser to recognize my keyboard input.

Thank you.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
davidson1
Offline
Joined: 2003-06-25

> Hello,
> great, since I do use the browser alomst exclusively
> only to embed a flash application I can't see
> mouseover problems either so this fix works fine for
> me.

So let me understand this: you are writing a Java application to embed a native html rendering component so that you can embed a Flash application?

You must have serious cahones. ;)

jroar
Offline
Joined: 2005-03-01

> So let me understand this: you are writing a Java
> application to embed a native html rendering
> component so that you can embed a Flash application?
>
>
> You must have serious cahones. ;)

Indeed, it also has to run on both Windows and Mac (I don't think I have to support 10.3), wasn't my choice though ;)
The thread on the mailing list looks promising, I hope somebody gets to the bottom of that soon,
jk

ashikaumanga
Offline
Joined: 2008-04-01

Hi guys,
I came across with a similar situation.In my application i had to embed Flash movie in Swing UI.I used JDIC and all worked fine with Windows (Except Ctrl+N issue).But in MAC Leopard the textfields,textarea in swf were disabled.

So modified "CC_DMWebKitView.mm:makeFirstResponder" method ,but i left the line
"[self window] makeFirstResponder : responder];" uncommented.
ie my "makeFirstResponder" method is like:

if(![responder isKindOfClass : [NSTextField class]]]]]
// if(![responder isKindOfClass : [NSTextField class]]){
// responder = [self window];
// }
[[self window] makeFirstResponder : responder];

Before compiling I had to modify "GNUmakefile" file since i am using Leopard.
ie .LDFLAGS should be:

"LDFLAGS = -dynamiclib -isysroot /Developer/SDKs/MacOSX10.5u.sdk -arch i386 -arch ppc"

then just built using "make" and used new "jnilib" file.
Now i can type in textareas,textfields in swf movie.

thanks and regards
umanga

Message was edited by: ashikaumanga

davea
Offline
Joined: 2008-08-02

Hi ashikaumanga

I don't have the experience / resources to apply your fix. Is there any possibility that you could post the modified jnilib file somewhere, or failing that email me a copy?

Thanks

DaveA ( dmaguard1110-javaforums@yahoo.co.uk )

ashikaumanga
Offline
Joined: 2008-04-01

Here is the fixed MAC library

Hope this helps..

[u]http://umanga.ifreepages.com/lab/libjdic.zip[/u]

Seems something wrong with the URL..Just copy the link and paste in in address bar.

Message was edited by: ashikaumanga

davea
Offline
Joined: 2008-08-02

Thanks a lot for that Ashikaumanga - seems to work just fine now.

I wonder if the jdic team will incorporate this fix in a new release for MAC?

DaveA

rajashree
Offline
Joined: 2008-02-11

Davidson,

I am using JDIC for embedding the webbrowser. I am having issues with the keyboard input events. I read your post, It would be of great help if you can proivde me the modified libjdic.jnilib.

Thanks,
Rajashree(rajashree.meganathan@sourcen.com)

jroar
Offline
Joined: 2005-03-01

Hello,
I'm having the same problem here. Is there any progress regarding this problem?
Or otherwise do any of you have an alternative to the jdic webbrowser for mac os x besides SWT? Because this is quite a matter for my application :-(

thanks,
Janni Kovacs

davidson1
Offline
Joined: 2003-06-25

I didn't get commit status from the project owners but my solution works. I'm not really about the mouse over issue that redfish mentions. I don't see any mouse over problems however, my usage of the browser component is limited.

My solution is to comment out the overloaded CC_DMWebKitView:makeFirstResponder method. You may want to apply these diffs and recompile the libjdic.jnilib:

[mark_davidson@blur jni]$ cvs diff CC_DMWebKitView.mm
Index: CC_DMWebKitView.mm
===================================================================
RCS file: /cvs/jdic/src/jdic/src/mac_os_x/native/jni/CC_DMWebKitView.mm,v
retrieving revision 1.2
diff -r1.2 CC_DMWebKitView.mm
612a613
> /*
621,626c622,627
< /*
< if(![responder isKindOfClass : [NSTextField class]]){
< responder = [self window];
< }
< [[self window] makeFirstResponder : responder];
< */
---
>
> // if(![responder isKindOfClass : [NSTextField class]]){
> // responder = [self window];
> // }
> // [[self window] makeFirstResponder : responder];
>
628a630
> */

This solution works for our purposes. Good luck!

Message was edited by: davidson1

jroar
Offline
Joined: 2005-03-01

Hello,
great, since I do use the browser alomst exclusively only to embed a flash application I can't see mouseover problems either so this fix works fine for me.

Janni Kovacs

PS: I had to change the buildscript though, to use the 1.5 sdk not the 1.4. Don't know what exactly caused the problem since I'm not into objective-c, however with 1.5 sdk - on leopard - it works (if anybody else should run into this problem)

davidson1
Offline
Joined: 2003-06-25

There seems to be an active discussion on this topic in the java-dev list at lists.apple.com.

Search for the March 2008 discussion thread with the subject: "CocoaComponent vs makeFirstResponder()"

http://lists.apple.com/archives/java-dev/

There is a lot of good information related to this issue in that thread. Use it to make your own decisions on commenting out the method and the impact it may have on earlier platforms like 10.3 and early versions of 10.4.

sairam71
Offline
Joined: 2007-04-17

any ideas? Has anyone gotten the browser to work on OS X in terms of being responsive to keyboard input?

davidson1
Offline
Joined: 2003-06-25

Eureka!

After a couple of hours of hacking, I think I have a solution to the OS X WebKit and Keyboard input issue. The problem seems to be the overloaded webView:makeFirstResponder method in CC_DMWebKitView.mm. If the responder is not a text type component then the responder will be set to the window. This is probably not a valid assumption.

The keyboard input worked in the Browser demo when I commented out the overloaded method.

Now I just have to figure out what I did. I'm not an Objective-C developer so I'm not sure about the side effects of this change.

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/...

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundament...

I've asked for developer status on this project. If I get it then I'll file an issue and check in my change after a code review.

At least we can move forward with the Mac OS X native browser.

--Mark

redfish
Offline
Joined: 2006-03-03

I'm running into the same problem and also discovered that it related to the makeFirstResponder method.

I think Dmitry's code relates to a previous version of WebKit where the responder coming in varied in class according to what kind of animal was requesting first responder status. This may have been true earlier, but now it seems that no matter what kind of thing the user clicks on, the class coming in is always WebHTMLView (a private class). So it's no longer possible to differentiate, the way Dmitry did.

If you don't implement makeFirstResponder, or you don't override the incoming responder the way Dmitry does, then you might find that mouseovers don't work. Sometimes you do need to make the window the first respoonder.

I've not so far found a solution to this, and nobody on apple-java-dev or webkit-sdk-dev has provided one either. So right now, my application supports keyboard but no mouseovers.

I *really* hope that we can get to the bottom of this one.

sairam71
Offline
Joined: 2007-04-17

After playing with it some more, I can right click and paste text into the field. Not sure if that helps narrow down the problem.