Loading of Javascript file

32 views
Skip to first unread message

dvarrin

unread,
Mar 20, 2012, 12:41:19 PM3/20/12
to Google Web Toolkit
Hi,

I want to use a virtual keyboard for some input fields on a web page
of my GWT website. In a normal HTML page, I would need to do the
following:

<html>
<head>
<script type="text/javascript" src="keyboard.js" charset="UTF-8"></
script>
<link rel="stylesheet" type="text/css" href="keyboard.css">
</head>

<body>
<input type="text" value="" class="keyboardInput">
</body>

(required files are available here: http://www.greywyvern.com/code/javascript/keyboard)

There is a javascript file and style sheet to include on the page, and
then all the input fields on which I want a virtual keyboard to be
assgned, I've to set their class to "keyboardInput".

I've added the keyboard.js and keyboard.css to the html page in my
application and then in the class creating the view I'm using:

<nameOfField>.setStyleName("keyboardInput");

Then the script should add the virtual keyboard image next to each
field of the class "keyboardInput".

when I check the result page, the field has is of the correct class,
and I've added an alert in the keyboard.js script and it is executed,
but no virtual keyboard image is displayed next to the field.

Any idea?

Thomas Broyer

unread,
Mar 20, 2012, 12:46:58 PM3/20/12
to google-we...@googlegroups.com
See "Advanced Stuff" on the page you linked to: the script runs at window.onload, and GWT code can run past this event. You'd have to call the VTI_attach() function via JSNI, passing myWidget.getElement() as the argument.

dvarrin

unread,
Mar 20, 2012, 12:56:25 PM3/20/12
to Google Web Toolkit
How can I do the call to the VKI_attach(elem) function with JSNI?

I tried to write $wnd.VKI_attach(name), but I'm getting an error
message telling that VKI_attach is not a function.

Adolfo Panizo Touzon

unread,
Mar 23, 2012, 4:32:59 AM3/23/12
to google-we...@googlegroups.com
I've seen in the keyboards.js

VKI_attach = function(elem) { ...... }
try to change the name of the function to something like function myKeyBoard(elem){...}
Then, in your gwt  java class, after the code is injected, call to the method myMethodCall. 
public final native void myMethodCall(Elem oneElem) /*-{
    $wnd.myKeyBoard(oneElem);
}-*/
;
My 2 cents, 
Adolfo


2012/3/20 dvarrin <daniel...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
El precio es lo que pagas. El valor es lo que recibes.
Warren Buffet
Reply all
Reply to author
Forward
0 new messages