Hi Steve. After reading a few rants/articles/etc, some authors (inc an Adobe engineer) seemed to think that this was required to ensure that the keys get captured properly under all circumstances. I too found that just the one focus call did the trick for my simple test file,. so feel free to remove it, if you app is working the way you want :)
Aran On Tue, Nov 17, 2009 at 10:14 AM, Steve Thames <[email protected]>wrote: > FYI, Aran, it does not seem to be required to set > “onkeydown=swf.focus()”. I found that doing “swf.focus()” in the onload > event is sufficient. It looks clearly like you are correct—the > addDomLoadEvent handler is being called too early. > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Aran Rhee > *Sent:* Wednesday, November 11, 2009 4:10 PM > > *To:* [email protected] > *Subject:* Re: Setting Focus to SWF in Firefox using SWFObject > > > > Yes (I was referring to something else). I was meaning the callback > function available on the swfobject embed methods. With your above code, you > have not guaranteed that the swf has actually been created before running > your code. > > > > e.g. > > > > <script type="text/javascript"> > > function doFocus(e) > > { > > //alert("e.success = " + e.success +"\ne.id = "+ > e.id +"\ne.ref = "+ e.ref); > > e.ref.focus(); > > } > > swfobject.embedSWF("focustest.swf", "myContent", "550", "400", > "9.0.0", false, false, {wmode:"opaque"}, false, doFocus); > > </script> > > > > The callback function (after checking for the success property) should only > run after the swf is actually on the page. > > > > > > The other thing you should ensure is that all your swfobject code is up in > the <head> so that the execution order is actually correct. If you have it > inline, then of course your code will only run once that part of the page is > actually loaded. > > > > > > That all being said, with the above example code, I can get the caret to > flash in FF etc, but you still need to click into the swf to actually type > anything which does not help you!!! ( BTW without opaque wmode, you cannot > even get the caret to flash...) > > > > > > <edit> > > > > After some more messing around (I hate it when things don't work), I > finally got it working in both IE and FF (note this still does not work in > Chrome or Safari (PC)). As you may have seen in other threads, you seem to > need to wait for some amount of time before trying to set focus in FF etc. > > > > Both the callback method and addDomLoadEvent seem to execute to early. Some > people hack it by adding a timer before calling focus, but that just seems > lame to me. Here is what I came up with: > > > > http://www.misterhee.com/tests/focus/focustest.html > > > > > > The only other methodolgy I have seen which I have not tried is to use > ExternalInterface to get flash to call a js method on load to then invoke > focus from the host page. Perhaps this will work across all browsers??? > > > > Unfortunately, I do not have any more spare time to dedicate to this right > now. Anyone else ever had to deal with this issue? > > > > > > Aran > > > > > > > > > > > > > > > > > > > > > > On Thu, Nov 12, 2009 at 2:09 AM, Steve Thames <[email protected]> > wrote: > > Aran, at the bottom of the code in my original post you will find: > > > > swfobject.addDomLoadEvent(function() { > document.getElementById("app").focus(); }); > > where “app” is the DIV container where the swf is loaded. > > > > This is the solution for setting focus suggested all over the web regarding > swfobject 2.0 and it works fine in IE. > > > > Did you mean something else? > > > > > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Aran Rhee > *Sent:* Tuesday, November 10, 2009 4:51 PM > > > *To:* [email protected] > *Subject:* Re: Setting Focus to SWF in Firefox using SWFObject > > > > window is the default wmode value if nothing is set. > > > > You should easily be able to set focus to the object with some simple js > like: > > document.getElementById("FlashObjectID").focus(); > > > > This is obviously a simplification, and you should ensure that you swf is > actually available before trying to call this method (use the swfobject > callback function) > > > > > > Aran > > > > > > On Wed, Nov 11, 2009 at 11:30 AM, Steve Thames <[email protected]> > wrote: > > Actually, I tried with opaque/transparent/window and no setting at all. No > differences. > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Aran Rhee > *Sent:* Tuesday, November 10, 2009 4:03 PM > > > *To:* [email protected] > *Subject:* Re: Setting Focus to SWF in Firefox using SWFObject > > > > Yes, this is a known Mozilla bug with wmode (amongst many others). > > > > The easiest solution is to avoid wmode = opaque/transparent if at all > possible... > > > > Aran > > > > On Wed, Nov 11, 2009 at 5:36 AM, Steve Thames <[email protected]> > wrote: > > Thanks for responding, Sam. > > Actually, the consensus I am finding is that this is a general Mozilla > issue. Some think it is related to setting *wmode* to *transparent* but I > find these results with any setting. As I said, it works fine in IE. Don’t > know yet about Opera or Safari. I am looking to find anyone that has found > a solution to this problem. > > > > I did find one site in which someone had apparently solved this but it > involved about three pages of Javascript code and I’m looking for something > a little easier than that. > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Sam Sherlock > *Sent:* Tuesday, November 10, 2009 10:03 AM > *To:* [email protected] > *Subject:* Re: Setting Focus to SWF in Firefox using SWFObject > > > > swfobject is working fine, this is a general flash issue - does using > traditional object/embed method rather than swfobject make it work? (I > would imagine not - why I see this as a general flash issue) > > > > I have found (but not tried it) > > > http://www.bigresource.com/FLASH-Creating-Keyboard-class-setting-the-focus-to-input-text-fields-uTOPHnuQQO.html > > > - S > > 2009/11/9 smthames <[email protected]> > > > Using SWFObject 2.0: > > <div id="app"></div> > > <style> > object:focus { outline: none; } > </style> > > <script type="text/javascript"> > > var flashvars = > { > AppPath: '<%=String.Format("{0}://{1}{2}", > Request.Url.Scheme, Request.Url.Host, ai.Path)%>' > }; > > var params = > { > allowScriptAccess: "always", > wmode: "transparent" > }; > > var attributes = > { > }; > > swfobject.embedSWF("flash/CAPTAClient.swf?128988943755758144", > "app", > "950", > "480", > "9", > '/CAPTA/include/expressInstall.swf', > flashvars, > params, > attributes); > > swfobject.addDomLoadEvent(function() { document.getElementById > ("app").focus(); }); > > </script> > </div> > > The SWF contains a username/password input panel. This works fine in > IE. In FF, the caret is flashing in the User Name field, as it > should, but no keyboard input works and will not work until the user > clicks on the SWF object, itself. Further, when the SWF is active, > tabbing will only tab through the SWF fields--not out into the browser > location bar. > > I don't care so much about the tabbing but would really like to know > how to allow the user to type into the focused input field without > having to click on the SWF. > > Anyone have any idea? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SWFObject" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/swfobject?hl=en -~----------~----~----~----~------~----~------~--~---
