PDA

View Full Version : numeric entry


tglines
04-11-2006, 08:52 AM
Anyone know how to limit entry into edittext to numbers only and how to right align the entry?

I've search this forum and see thaere are ways to use external calls but, I must admit, I don't understand how to use them. I am fairly new at this and javascript.

tglines
04-11-2006, 10:25 AM
Never mind, I finally figured it out. Thx.

julian_lp
04-11-2006, 02:51 PM
Could you explain how to achieve that? It's good to share I think...

regards - julian

tglines
04-12-2006, 05:01 AM
Sure, I set pattern="[0-9]*" and it works. I still haven't figured out how to right justify the entry however.

julian_lp
04-12-2006, 03:14 PM
sweet ;)

regards - julian

tudor_19
04-28-2006, 05:43 AM
you can start from this piece of code:

<canvas>

<class name="myedit" extends="inputtext">
<method event="oninit">
<![CDATA[
var format = new TextFormat();
format.align="right";
__LZtextclip.setTextFormat(format);
]]>
</method>
<method event="onblur">
__LZtextclip.hscroll=0;
</method>
</class>
<myedit name="12" width="100" bgcolor="#ffcccc" x="10" y="50">
1234567
</myedit>
<myedit name="123" width="100" bgcolor="#ffcccc" x="10" y="100">
23111
</myedit>
</canvas>


if you try to align it inside an edittext things become harder...

tglines
04-28-2006, 10:24 AM
That seems to work, however, I was trying to use edittext.

tudor_19
04-28-2006, 11:05 AM
for an edittext you should write something like this:

<canvas>

<class name="myedit" extends="edittext">
<method event="oninit">
<![CDATA[
var format = new TextFormat();
format.align="right";
field.__LZtextclip.setTextFormat(format);
]]>
</method>
<method event="onblur">
field.__LZtextclip.hscroll=0;
</method>
</class>
<myedit name="12" width="100" bgcolor="#ffcccc" x="10" y="50">
1234567
</myedit>
<myedit name="123" width="100" bgcolor="#ffcccc" x="10" y="100">
23111
</myedit>
</canvas>


but once you type something into it, it will align it to the left.I had a working version of an edittext , with right alignment, but it is on my computer at work, so until monday I can help you much..

daniel.may
07-11-2006, 11:10 AM
hello,

the method suggested by tudor_19 didn't work for me - could it be that it doesn't work for OL 3.3.1 anymore? Here's my code snippet:


<class name="numValue" extends="edittext">
<method event="oninit">
<![CDATA[
var format = new TextFormat();
format.align="right";
field.__LZtextclip.setTextFormat(format);
]]>
</method>

<method event="onblur">
field.__LZtextclip.hscroll=0;
</method>
</class>

(...)

<numValue x="250" y="35" width="90" height="24" datapath="preis/text()"/>


The text is still displayed left aligned. Any clues? related question: what am I doing by setting field.__LZtextclip.setTextFormat(format)? Is this documented somewhere?

Greetings
Daniel

bytebodger
07-17-2006, 05:34 AM
This is the solution that I came up with this weekend:


<class name="rightEditText" extends="edittext">
<method event="onclick">
LzFocus.setFocus(this.field);
</method>
<method event="oninit">
this.rightAlignText();
this.field.setBGColor();
</method>
<method name="rightAlignText">
this.field.setAttribute("xoffset", ((this.width - 5 - this.field.getTextWidth()) * -1));
if (typeof(this.checkTextAlignmentDelegate) == "undefined") {
this.checkTextAlignmentDelegate = new LzDelegate(this, "rightAlignText");
LzTimer.addTimer(this.checkTextAlignmentDelegate, 10);
} else {
LzTimer.resetTimer(this.checkTextAlignmentDelegate , 10);
}
</method>
</class>
<rightEditText name="numericText" maxlength="8" width="75" pattern="[0-9\.]*" text="0.49" />