Re: [Xsltforms-support] I18N: Bug and proposed fix for Windows Asian IME with xf:input DOMActivate
Brought to you by:
alain-couthures
From: Alain C. <ala...@ag...> - 2011-05-17 20:39:22
|
Please check r503 for Windows Asian IME support. I currently have problems for testing with IE7 and IE8 while it seems to be OK with IE6. Thanks! -Alain Le 03/05/2011 22:08, Leigh L Klotz Jr a écrit : > Asian language IME systems are used to convert keyboard events into text. > On Windows (at least), pressing the Enter key to accept a proposed > conversion also incorrectly dispatches DOMActivate to the input control. > > In this situation, the Windows IME sends keyup charcode 13 but it has > not previously sent keydown or keypress charcode 13. > XSLTForms listens on keyup only, and therefore wrongly dispatches > DOMActivate on charcode 13 during the input editing process. > > A proposed fix for XSLTForms would be to listen to keydown, keypress, > and keep a state flag for input. > If keydown or keypress charcode is not 13, then the state flag should > be set to false. > In keyup, only if the state flag is true should keyup charcode 13 > dispatch DOMActivate. > > Here is a test case, with one incremental and one regular xf:input. > > <?xml version="1.0"?> > <?xml-stylesheet href="/xsltforms/xsltforms.xsl" type="text/xsl"?> > <?css-conversion no?> > <?xsltforms-options debug="no" lang="en_US" css="no"?> > <html xmlns="http://www.w3.org/1999/xhtml" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:xf="http://www.w3.org/2002/xforms" > xmlns:ev="http://www.w3.org/2001/xml-events"> > <head> > <title>Japanese DOMActivate</title> > <xf:model> > <xf:instance> > <data xmlns=""> > <term /> > </data> > </xf:instance> > </xf:model> > </head> > <body> > <xf:input ref="term" incremental="true"> > <xf:label>Text</xf:label> > <xf:message level="modal" ev:event="DOMActivate">hi</xf:message> > </xf:input> > <xf:input ref="term"> > <xf:label>Text</xf:label> > <xf:message level="modal" ev:event="DOMActivate">hi</xf:message> > </xf:input> > </body> > </html> > > Here are some references which propose the state flag solution: > http://getsatisfaction.com/springpartners/topics/when_create_a_stuff_via_japanese_ime_enter_is_misidentified > http://springpadit.com/shin3/note/keyeventsviajapaneseime > http://groups.google.com/group/codemirror/browse_thread/thread/5a2db8b81f0c8535/b700a1493f3d7feb?lnk=raot&fwc=2 > > Here is a proposed solution for XSLTForms that stores the state > variable in this.wasEnter (this == HTML input object). > You may prefer a different implementation. > > I have tested this in Windows FF4, IE8, Chrome 11. > I was unable to test it in IETester so I have no tests for IE6, IE7, > or IE9. > I have not tested this with IME on any other platforms. > > diff -c2 xsltforms.js~ xsltforms.js > *** xsltforms.js~ 2011-05-02 14:35:04.000000000 -0700 > --- xsltforms.js 2011-05-03 12:59:25.387599997 -0700 > *************** > *** 4502,4505 **** > --- 4502,4507 ---- > XSLTFormsEvent.attach(input, "keyup", > XFInput.keyUpActivate); > } > + XSLTFormsEvent.attach(input, "keydown", > XFInput.keyDownActivate); > + XSLTFormsEvent.attach(input, "keypress", > XFInput.keyPressActivate); > } else { > if (this.incremental) { > *************** > *** 4559,4572 **** > > > > > XFInput.keyUpActivate = function(a) { > var xf = XFControl.getXFElement(this); > ! if (a.keyCode == 13) { > xforms.openAction(); > xf.valueChanged(this.value || ""); > XMLEvents.dispatch(xf, "DOMActivate"); > xforms.closeAction(); > ! } > }; > > --- 4561,4583 ---- > > > + XFInput.keyDownActivate = function(a) { > + this.wasEnterKey = (a.keyCode == 13); > + } > + > + XFInput.keyPressActivate = function(a) { > + this.wasEnterKey = this.wasEnterKey && (a.keyCode == 13); > + } > > > XFInput.keyUpActivate = function(a) { > var xf = XFControl.getXFElement(this); > ! if (this.wasEnterKey && a.keyCode == 13) { > xforms.openAction(); > xf.valueChanged(this.value || ""); > XMLEvents.dispatch(xf, "DOMActivate"); > xforms.closeAction(); > ! } else { > ! this.wasEnterKey = false; > ! } > }; > > *************** > *** 4576,4580 **** > XFInput.keyUpIncrementalActivate = function(a) { > var xf = XFControl.getXFElement(this); > ! if (a.keyCode == 13) { > xforms.openAction(); > xf.valueChanged(this.value || ""); > --- 4587,4591 ---- > XFInput.keyUpIncrementalActivate = function(a) { > var xf = XFControl.getXFElement(this); > ! if (this.wasEnterKey && a.keyCode == 13) { > xforms.openAction(); > xf.valueChanged(this.value || ""); > *************** > *** 4582,4585 **** > --- 4593,4597 ---- > xforms.closeAction(); > } else { > + this.wasEnterKey = false; > if (xf.delay && xf.delay > 0) { > if (xf.timer) { > *************** > *** 10190,10192 **** > > > > Leigh. > > > ------------------------------------------------------------------------------ > WhatsUp Gold - Download Free Network Management Software > The most intuitive, comprehensive, and cost-effective network > management toolset available today. Delivers lowest initial > acquisition cost and overall TCO of any competing solution. > http://p.sf.net/sfu/whatsupgold-sd > > > _______________________________________________ > Xsltforms-support mailing list > Xsl...@li... > https://lists.sourceforge.net/lists/listinfo/xsltforms-support |