i found a *terrible* way to work around this issue, but it works.  i moved the 
field.setSelection call to a delegate, which allows it to work:

===
                        var del = new lz.Delegate(this, "selectEnd");
                        lz.Timer.addTimer(del, 1);
                </method>
                <method name="selectEnd" args="ignore">
                        this.field.setSelection(this.value.length);
                </method>
===

this should help narrow down what the problem is with the TLF framework.

augusto.

On May 22, 2012, at 4:00 PM, augusto callejas wrote:

> ps-  i'm using a nightly build of openlaszlo (5.0.x-19545)
> 
> On May 22, 2012, at 3:58 PM, augusto callejas wrote:
> 
>> hi-
>> 
>> i'm writing a custom edittext class that formats my text based on input.  
>> included here is a simplified version that separates text by dashes.
>> the screenshot shows two instances of my class, one with 
>> "hasdirectionallayout" not set and another with "hasdirectionallayout" set 
>> to true:
>> 
>>   http://i.imgur.com/AoBSN.png
>> 
>> the first editext instance shows the proper behavior: you type a character, 
>> the character is displayed and appends a "-", and sets the selection 
>> position at the end of the field, where you can continue typing more 
>> characters.
>> 
>> the second edittext instance shows incorrect behavior: you type a character, 
>> the character is displayed and appends a "-", but it doesn't set the 
>> selection position at the end of the field - it loses focus, so you can't 
>> type into the edittext unless you click back into it.
>> 
>> two points to make:
>> 
>> 1) setting "hasdirectionallayout=true" changes the behavior of the edittext, 
>> which seems wrong.
>> 2) my general approach of overriding "setValue" in order to format my text 
>> may not be optimal 
>> 
>> i'm interested in the answer to point 1 more than point 2 - unless there is 
>> a different approach to point 2 that still allows me to use 
>> "hasdirectionallayout=true".
>> 
>> sample code below.
>> 
>> thanks,
>> augusto.
>> 
>> ====
>> <canvas height="100%" width="100%">
>>         <simplelayout axis="y" spacing="10"/>
>> 
>>         <class name="dashes" extends="edittext">
>>                 <attribute name="process" type="boolean" value="true"/>
>>                 <method name="setValue" args="t, isinitvalue=null">
>>                         if (t == null || t == '') {
>>                                 return;
>>                         }
>>                         if (!process) {
>>                                 super.setValue(t, isinitvalue);
>>                                 return;
>>                         }
>> 
>>                         t += "-"; 
>>                         setAttribute('process', false);
>>                         setAttribute('text', t);
>>                         setAttribute('process', true);
>> 
>>                         if (this['field'] != null)
>>                                 field.setSelection(t.length);
>>                 </method>
>>         </class>
>> 
>>         <text>works:</text>
>>         <dashes/>
>>         <text>doesn't work:</text>
>>         <dashes hasdirectionallayout="true"/>
>> </canvas>
>> ====
> 

Reply via email to