Solved

Applets and browser interaction

Posted on 2000-04-11
9
564 Views
Last Modified: 2013-11-19
Hi there,
I'm using some mask edit applets in HTML pages. What I want is to give the focus to the next/previous control (or applet) in the page when pressing <tab> / <shift>+<tab>.
As my applets are treating the keyboard input, the tabIndex property of the <Applet> tag has no effect (the browser don't know the <tab> key has been pressed).
I found a solution by using some functions (like isTabPressed()) in the applets. Those functions are called (within the page) every 10 milliseconds after the onFocus.

The HTML code looks like this :

<SCRIPT FOR=EDIT1 EVENT=onfocus>
  window.setTimeout("checkTab(EDIT1)", 10);
</SCRIPT>

function checkTab(S)
{
  if (S.isTabPressed())
       document.all.item(S.NextID)._focus();
  else if (S.isShiftTabPressed())
      document.all.item(S.PrevID)._focus();
  else
    window.setTimeout("checkTab("+S.id+")", 10);
}

Unfortunately, i can't use it :
- i don't want to add JavaScript events for that
- the tab order should be respected also for the other components (not only for the applets)
- as my HTML code is the result of an interpretation, I don't know which ID will be next in advance

I was thinking the keyPressed event was
first fired in the browser and then sent to the applet, but that's not true.
I tried then to send the keyPressed message from the applet up to the browser but i couldn't find the appropriate way...

Can anybody help me with my tab-keeping applets ?

0
Comment
Question by:Le_Ron
  • 4
  • 4
9 Comments
 
LVL 1

Expert Comment

by:phutson
ID: 2705726
Do you not want any java script. If you don't mind some java script then I would make the buttons regular html buttons that use the onClick property to call the appropriate java method in the applet such as
onclick="document.nextPrevApplet.next();"

-Philip
0
 

Author Comment

by:Le_Ron
ID: 2706831
Hi Philip,

If you have a html form containing edits or check boxes, ... they have a tab order. That means when you press the tab key, the focus is given to the following control. The problem i'm experiencing is that i use applets which intercept the keyPressed event, so the browser cannot handle the tab in the usual way.

What i want to know is 'how can i tell the browser the tab key has been pressed from within an applet'.
0
 
LVL 1

Expert Comment

by:phutson
ID: 2709618
I looked for a way to generate a key event in jscript or java and was unable to find one so the only way I could come up with to move focus is the following. Add the onfocus to the applet tag that sets a jscript variable (it looks like your working in ie 5.x) to point to it's self (onfocus="setSelf(document.appletOne)") then have another jscript function that will call the blur method of the object that is refereced to by the variable that is set with the setSelf jscript function. Then from within the applet call the jscript function that calls the blur function.
-Philip
0
 

Author Comment

by:Le_Ron
ID: 2710839
Hi Philip,

You wrote:

>>Then from within the applet call the
>>jscript function that calls the blur
>>function

Alright, but how can i do that ? Is there a special function to send messages to the browser ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:phutson
ID: 2712374
Which java are you using sun or ms. I do not have the j++/jscript method of calling jscript functions but I am looking for it. The method I show below uses sun's java and a netscape class but the resulting applet works in both ie 5.x or netscape 4.0x.
Netscape has an almost acceptable explanation of the javascript to java communication technology (live connect
http://developer.netscape.com/docs/manuals/liveconnect.html
from there there are a few links that help fill the information but it is still severly lacking) another reference for liveconnect is in O'Reilly's JavaScript: The definitive guide third edition (isbn 1-56592-392-8).

Here is an example (from an applet I just recently finished) of a java method to call a javascript method that take a calling argument of a string. The netscape.javascript.JSObject class is within java40.jar which is in the netscape program directory structure.

import netscape.javascript.JSObject;

      public void setDate(String inDate){
            String[] date = new String[1];
            
            date[0] = inDate;
            JSObject win = JSObject.getWindow(this);
            win.call("setData",date);
      }


For you your java method you could do a lot less. It would look something like this. tabMe is the name of the javascript function.

import netscape.javascript.JSObject;

      public void blurMe(){
            JSObject win = JSObject.getWindow(this);
            win.call("tabMe");
      }

-Philip
0
 
LVL 1

Accepted Solution

by:
phutson earned 100 total points
ID: 2713815
Okay here is the only information I could find on j++. The class that allows java to jscript/html access is com.ms.wfc.html and a place to start looking for information
http://msdn.microsoft.com/library/techart/msdn_dhtmljava.htm

jscript to java is simply a matter of something like
document.myApplet.runThis()
or
set app1 = document.myApp
app1.showthis()

The thing to remember is that any public method or member of an applet is accessible to javascript or jscript, including public static members or methods such as system.out.println() which makes for some very interesting posibilities.

-Philip
0
 

Author Comment

by:Le_Ron
ID: 2721808
Tank you for your interest in my question, but i got my own solution now. Anyway, your informations are useful ,and i'll give you some points for that !

Thanks
0
 

Expert Comment

by:Sesh
ID: 2765220
how did you end up doing it?
0
 

Author Comment

by:Le_Ron
ID: 2768548
Well, i call a function in the onLoad event. that function runs through all applets in the page and tests, for each of them, a property isTabPressed and isShiftTabPressed. Those boolean members are set in within the applet when tab - or shift-tab - is pressed.
The function ends by calling itself after a timeout of 0.1 second.

If isTabPressed or isShiftTabPressed is true, another JavaScript function is called with the name of the applet as an argument, giving focus to the next or previous control on the page. In order to do this, a loop is done over all elements of the document, looking for the applet. When it has been found, i just have to take the previous one or the next one in the array and give the focus to it.

If you're interrested in it, i can send you some code (if i find it back). Because after all, i'm using ATL objects that have normal behavior regarding the tab and shift-tab.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 79
reverse digits of a number using for loop 5 36
Windows 10 IE Certificate Issue 10 42
Way to decrease size of apk file 9 43
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now