History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-3907
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: -- --
Assignee: Unassigned
Reporter: André Bargull
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

edittext and inputtext may fire onfocus resp. onblur twice

Created: 23/Apr/07 11:39 AM   Updated: 21/Aug/07 03:13 PM
Component/s: Components - LZ
Affects Version/s: 4.0.0
Fix Version/s: 4.0.5WaffleCone

Time Tracking:
Not Specified

Severity: Minor
Fixed in Change#: 6,132
Runtime: N/A
Flags: Regression
Fix in hand: False


 Description  « Hide
An edittext may fire onfocus resp. onblur two times under some circumstances.
This behaviour is a regression against OL3.3.3!

DHTML-Runtime isn't affected by the onblur-issue, "just" onfocus will be fired twice.


Please restart the OL-app after every test:
<canvas debug="true" >
  <view name="'blue'" clickable="true" focusable="true" width="100" height="100" bgcolor="blue" >
    <handler name="onblur" >
      Debug.write( "onblur:", this );
    </handler>
    <handler name="onfocus" >
      Debug.write( "onfocus:", this );
    </handler>
  </view>
  
  <view name="'red'" clickable="true" focusable="true" x="120" width="100" height="100" bgcolor="red" >
    <handler name="onblur" >
      Debug.write( "onblur:", this );
    </handler>
    <handler name="onfocus" >
      Debug.write( "onfocus:", this );
    </handler>
  </view>
  
  <view name="'green'" x="240" width="100" height="100" bgcolor="green" />
  
  <edittext name="'edittext'" x="360" >
    <handler name="onblur" >
      Debug.write( "onblur:", this );
    </handler>
    <handler name="onfocus" >
      Debug.write( "onfocus:", this );
    </handler>
  </edittext>
  
  <view y="120" layout="axis:y;spacing:10" >
    <text text="Test 1: Click on the blue rectangle, then click on the red rectangle" />
    <text x="15" text="onfocus(blue) -> onblur(blue) -> onfocus(red)" />
    
    <text text="Test 2: Click on the blue rectangle, then click on the green rectangle" />
    <text x="15" text="onfocus(blue)" />
    
    <text text="Test 3: Click on the blue rectangle, then click on the edittext" />
    <text x="15" text="onfocus(blue) -> onblur(blue) -> onfocus(edittext) -> onfocus(edittext)" />
    
    <text text="Test 4: Click on the edittext, then click on the blue rectangle" />
    <text x="15" text="onfocus(edittext) -> onfocus(edittext) -> onblur(edittext) -> onfocus(blue)" />
    
    <text text="Test 5: Click on the edittext, then click on the green rectangle" />
    <text x="15" text="onfocus(edittext) -> onfocus(edittext) -> onblur(edittext) -> [onblur(edittext) (swf-only)]" />
  </view>
</canvas>

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jennifer Schachter - 25/Apr/07 02:21 PM
<inputtext> also fires two onblur and two onfocus events.

Frisco Del Rosario - 25/Apr/07 03:02 PM
Verified the <inputtext> variation, too, and changed summary therefore.

André Bargull - 23/Jul/07 02:19 PM
@Frisco
As <inputtext> is also affected, you should probably change the field "Component/s" from "Components - LZ" to "LFC" to give this issue at least somehow a higher priority.

Max Carlson - 17/Aug/07 03:32 PM
Author: max
Date: 2007-08-17 15:29:20 -0700 (Fri, 17 Aug 2007)
New Revision: 6132

Modified:
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzInputText.lzs
Log:
Change 20070817-maxcarlson-I by maxcarlson@plastik on 2007-08-17 12:08:41 PDT
    in /Users/maxcarlson/openlaszlo/wafflecone
    for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

Summary: Fix duplicate onfocus and onblur events

New Features:

Bugs Fixed: LPP-3907 - edittext and inputtext may fire onfocus resp. onblur twice

Technical Reviewer: promanik
QA Reviewer: jcrowley
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: LzInputTextSprite.as - Fix test for current focus in __handlelostFocus().

LzInputTextSprite.lzs - Track current focus/blur state to avoid sending duplicate events.
    

Tests: Testcase from LPP-3907 passes in swf and dhtml.



Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as 2007-08-17 22:22:51 UTC (rev 6131)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as 2007-08-17 22:29:20 UTC (rev 6132)
@@ -256,8 +256,8 @@
   * @access private
   */
 TextField.prototype.__handlelostFocus = function ( ){
- //Debug.write('lostfocus', this.__lzview.hasFocus, dunno, LzFocus.lastfocus, this, LzFocus.getFocus(), this.__lzview);
- if (this.__lzview.hasFocus) {
+ //Debug.write('lostfocus', this.__lzview.hasFocus, LzFocus.lastfocus, this, LzFocus.getFocus(), this.__lzview, this.__lzview.inputtextevent);
+ if (this.__lzview == LzFocus.getFocus()) {
         LzFocus.clearFocus();
         if (this.__lzview) this.__lzview.inputtextevent('onblur');
     }

Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzInputText.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzInputText.lzs 2007-08-17 22:22:51 UTC (rev 6131)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzInputText.lzs 2007-08-17 22:29:20 UTC (rev 6132)
@@ -162,20 +162,27 @@
 
 /** @access private */
 function _gotFocusEvent(){
+ this._focused = true;
     this.sprite.gotFocus();
 }
 
 /** @access private */
 function _gotBlurEvent(){
+ this._focused = false;
     this.sprite.gotBlur();
 }
 
 // Receive input text events from sprite
 function inputtextevent (eventname, value){
+ //Debug.warn('inputtextevent', eventname, value);
+ if (eventname == 'onfocus' && this._focused) return;
+ if (eventname == 'onblur' && ! this._focused) return;
     if (eventname == 'onfocus' || eventname == 'onmousedown') {
+ this._focused = true;
         if (LzFocus.getFocus() != this) {
             var tabdown = LzKeys.isKeyDown('tab');
             LzFocus.setFocus(this, tabdown);
+ return;
         }
     } else if (eventname == 'onchange') {
         //multiline resizable fields adjust their height
@@ -186,7 +193,9 @@
         }
         if (this.ontext.ready) this.ontext.sendEvent(value);
         return;
- }
+ } else if (eventname == 'onblur') {
+ this._focused = false;
+ }
     if (this[eventname].ready) this[eventname].sendEvent(value);
 }
 


_______________________________________________
Laszlo-checkins mailing list
Laszlo-checkins@openlaszlo.org
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Mamye Kratt - 21/Aug/07 03:13 PM
(wafflecone branch local build r6169)
Test now works in swf7, swf8, and dhtml.