From xap-commits-return-567-apmail-incubator-xap-commits-archive=incubator.apache.org@incubator.apache.org Fri Oct 13 04:10:40 2006 Return-Path: Delivered-To: apmail-incubator-xap-commits-archive@locus.apache.org Received: (qmail 98678 invoked from network); 13 Oct 2006 04:10:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Oct 2006 04:10:40 -0000 Received: (qmail 66045 invoked by uid 500); 13 Oct 2006 04:10:40 -0000 Delivered-To: apmail-incubator-xap-commits-archive@incubator.apache.org Received: (qmail 66033 invoked by uid 500); 13 Oct 2006 04:10:39 -0000 Mailing-List: contact xap-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: xap-dev@incubator.apache.org Delivered-To: mailing list xap-commits@incubator.apache.org Received: (qmail 66024 invoked by uid 99); 13 Oct 2006 04:10:39 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Oct 2006 21:10:39 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Oct 2006 21:10:39 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 6679F1A981A; Thu, 12 Oct 2006 21:10:18 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r463557 - in /incubator/xap/trunk: WebContent/examples/widgets/AttributeTester.js WebContent/examples/widgets/textField.xal src/xap/bridges/dojo/TextFieldBridge.js Date: Fri, 13 Oct 2006 04:10:18 -0000 To: xap-commits@incubator.apache.org From: mturyn@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061013041018.6679F1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: mturyn Date: Thu Oct 12 21:10:17 2006 New Revision: 463557 URL: http://svn.apache.org/viewvc?view=rev&rev=463557 Log: Bridge methods for onEdit and onTextChange seem o.k.---the example's handler for onTextChange falls down for non-alphabetic chars. Modified: incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js incubator/xap/trunk/WebContent/examples/widgets/textField.xal incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js Modified: incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js?view=diff&rev=463557&r1=463556&r2=463557 ============================================================================== --- incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js (original) +++ incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js Thu Oct 12 21:10:17 2006 @@ -21,6 +21,26 @@ alert(event); } +// Don't want to trigger an additional onEdit by popping up +// an alert() box, which would make the textfield lose focus---so write it here +AttributeTester.prototype.reportTextFieldEventWithoutAlert = function(event){ + var sourceElement = event.source ; + var charCode = event.originalEvent.keyCode ; +// if ( charCode < 65 || charCode>123 ){ +// return ; +// } + if( ! event.originalEvent.shiftKey ){ + charCode += 32 ; + } + var charr = String.fromCharCode(charCode); + + sourceElement.setAttribute("text","" + //+ sourceElement.getAttribute("text") + + event.event+"[" + charr +"]; " + ) ; +} + + //IMPORTANT this works if you remove the same thing twice, //no error. BEcause we still found element in hashtable? AttributeTester.prototype.insertBefore = function( element ){ Modified: incubator/xap/trunk/WebContent/examples/widgets/textField.xal URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/textField.xal?view=diff&rev=463557&r1=463556&r2=463557 ============================================================================== --- incubator/xap/trunk/WebContent/examples/widgets/textField.xal (original) +++ incubator/xap/trunk/WebContent/examples/widgets/textField.xal Thu Oct 12 21:10:17 2006 @@ -14,6 +14,7 @@ Modified: incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js?view=diff&rev=463557&r1=463556&r2=463557 ============================================================================== --- incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js (original) +++ incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js Thu Oct 12 21:10:17 2006 @@ -50,6 +50,7 @@ //add listener last so we don't fire for the initial set dojo.event.connect(this.getPeer(), "onblur",this,"onblur"); + dojo.event.connect(this.getPeer(), "onkeyup",this,"onTextChange"); } xap.bridges.dojo.TextFieldBridge.prototype.getPeerString = function(){ @@ -87,6 +88,35 @@ clientEvent.text = text; this.fireEvent("onEdit",null,null,clientEvent); } + +/** + * Fires an onTextChange() iff the field has lost focus + * and there has been a change in the text: +**/ +xap.bridges.dojo.TextFieldBridge.prototype.onTextChange = function( kbdEvent ){ + // Only do the rest if not read-only: + if( this.getPeer().isReadOnly() ){ + return false; + } + var oldText = this.getElement().getAttribute(xap.xml.XmlTokens.TEXT) ; + var newText = this.getPeer().getText(); + + var clientEvent = new xap.session.ClientEvent(this.getElement(),this.getSession()); + + // fire an onTextChange() iff there's been a change: + if( oldText != newText ){ + // I don't think we should change the element on + // every keystroke: + //this.writeBackAttribute(xap.xml.XmlTokens.TEXT,newText); + clientEvent.text = newText; + clientEvent.originalEvent = kbdEvent ; + this.fireEvent("onTextChange",null,null,clientEvent); + } + return false ; +} + + + xap.bridges.dojo.TextFieldBridge.prototype.setMaxLengthAttribute = function( nMax ){