Skip to main content

Delete char in TextField

27 replies [Last post]
alesincri
Offline
Joined: 2008-05-29
Points: 0

When I try to delete a char into a Texfield component, I obtain a dot in the field, and the character isn't erased.
I've tried to extend the TextField class and I have used deleteChar() with the same result.
I use PhoneMe VM in HTC P6500.

Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
awandi
Offline
Joined: 2008-01-18
Points: 0

Hi,
setting Display.setSoftkeyCodes(0, 0, , 0) does not work. Instead, I am successful with Display.setSoftkeyCodes(, 0, 0, 0). Strange, isn't it?
Is this a bug? Or am I getting something wrong? I am using the library distributed with LWUIT_20080714.

Regards, awandi

chen

Hi,
You should also setQwerty to true, besides my previous post.

lwuit-users@mobileandembedded.org wrote:
> Hi,
> setting Display.setSoftkeyCodes(0, 0, , 0) does not work. Instead, I am successful with Display.setSoftkeyCodes(, 0, 0, 0). Strange, isn't it?
> Is this a bug? Or am I getting something wrong? I am using the library distributed with LWUIT_20080714.
>
I don't understand how this is what solved your issue, have you
specified the correct key code of the delete key?

Regards,
Chen

> Regards, awandi
> [Message sent by forum member 'awandi' (awandi)]
>
> http://forums.java.net/jive/thread.jspa?messageID=291581
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

sawal_xp
Offline
Joined: 2008-02-12
Points: 0

hi..
about keycode, Display.setSoftkeyCodes(0, 0, , 0)
how to get the key code from our backspace button from our qwerty keybord..?
i don't know the key code from my backspace in my qwerty keybord E90....

Shai Almog

Hi,
to detect keyCodes just override Form.keyPressed(int keyCode) and
print out the key code. You can set the number of the key code to a
label e.g.:

final Label l = new Label("Code");
Form f = new Form("Key Code") {
public void keyPressed(int code) {
l.setText("" + code);
}
};
f.addComponent(l);
f.show();

> hi..
> about keycode, Display.setSoftkeyCodes(0, 0, , 0)
> how to get the key code from our backspace button from our qwerty
> keybord..?
> i don't know the key code from my backspace in my qwerty keybord
> E90....
> [Message sent by forum member 'sawal_xp' (sawal_xp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=292020
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

sawal_xp
Offline
Joined: 2008-02-12
Points: 0

hi shai..
i have get my backspace keycode from my qwerty keyboard, the number is 8, and set

Display display = Display.getInstance();
display.setSoftkeyCodes(0, 0, 8, 0);

it's work good, much better now..:)

but Shai, i think, it's more effective if when we click the backspace, we not to enter the textfield or the layer not change to mode large textarea, just editting in the textfield focus..
may be it's my suggestion..:)
or can the textfield do like i want it?

Shai Almog

Hi Sawal,
there is an issue with clear commands and the text field which will
be fixed soon. This might have prevented previous attempts with the
clear command from working.

> hi shai..
> i have get my backspace keycode from my qwerty keyboard, the number
> is 8, and set
>
> Display display = Display.getInstance();
> display.setSoftkeyCodes(0, 0, 8, 0);
>
> it's work good, much better now..:)
>
> but Shai, i think, it's more effective if when we click the
> backspace, we not to enter the textfield or the layer not change to
> mode large textarea, just editting in the textfield focus..
> may be it's my suggestion..:)
> or can the textfield do like i want it?
> [Message sent by forum member 'sawal_xp' (sawal_xp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=293224
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

achie3xis
Offline
Joined: 2008-08-26
Points: 0

Yups..I'm to success when i delete the character,,Thanks shai..

Asri

Message was edited by: achie3xis

sawal_xp
Offline
Joined: 2008-02-12
Points: 0

hi all..
i get problem with textfield about T9 command,
this is the thread talk about bug T9 problem :
[url]http://forums.java.net/jive/thread.jspa?threadID=46601&tstart=0[/url]

so i want to not use this T9 command..
i disable the softkey with this code

textfield.setusesofkey(false);

if i not use the softkey, so my qwerty backspace doesn't work..
how to make my backspace qwerty work to delete when usesoftkey is false..?

Shai Almog

Hi,
which device?

You can detect the keyCode for the backspace key and set it to the
display class either by using setSoftkeyCodes or by using the jad
attributes mentioned in the forum such as SoftKey-Clear.

> hi all..
> i get problem with textfield about T9 command,
> this is the thread talk about bug T9 problem :
> [url]http://forums.java.net/jive/thread.jspa?threadID=46601&tstart=0
> [/url]
>
> so i want to not use this T9 command..
> i disable the softkey with this code
>
> textfield.setusesofkey(false);
>
> if i not use the softkey, so my qwerty backspace doesn't work..
> how to make my backspace qwerty work to delete when usesoftkey is
> false..?
> [Message sent by forum member 'sawal_xp' (sawal_xp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=298940
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

sawal_xp
Offline
Joined: 2008-02-12
Points: 0

my code is like thi

Display.getInstance().setSoftkeyCodes(0, 0, 8, 0); // num 8 is keycode num for backspce

and to disable T9 and Clear command, i use :

textfield.setusesofkey(false);

if i use this code, disable the softkey, i cann't use my backspace to delete the char in textfield...

Shai Almog

That line of code is incorrect.
Test to see your actual keyCodes and use them as explained in several
threads here.

> my code is like thi
>
> Display.getInstance().setSoftkeyCodes(0, 0, 8, 0); // num 8 is
> keycode num for backspce
>
> and to disable T9 and Clear command, i use :
>
> textfield.setusesofkey(false);
>
> if i use this code, disable the softkey, i cann't use my backspace
> to delete the char in textfield...
> [Message sent by forum member 'sawal_xp' (sawal_xp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=298972
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

ionutianasi
Offline
Joined: 2008-11-10
Points: 0

1. In fact, I think he's right. If you use the jad attribute ( SoftKey-Clear : 8 ) to define the code for the actual(physical) clear key and then use setUseSoftkeys(false) you'll disable the physical clear key too. I would expect setUseSoftkeys to just not show the T9/Clear Commands, not to disable the physical clear key completely ( now you just have a textfield in which you can type but you can't delete anything )

2. Since setSoftkeyCodes(int left, int right, int clear, int back) is depracted and I dont want to use the jad to set the code for the clear key, how can I do it with LWUITImplementation, as indicated in the doc ?

thanks

Shai Almog

The issue of clear key not mapping without the command being added is
an issue we fixed quite a while back (its in the issue tracker).

setSoftkeyCodes will no longer work since it will break the
portability of Display, we are still fleshing out an alternative
method to do this without the jad but currently this isn't
recommended and probably will never be recommended since it will
break portability.

> 1. In fact, I think he's right. If you use the jad attribute
> ( SoftKey-Clear : 8 ) to define the code for the actual(physical)
> clear key and then use setUseSoftkeys(false) you'll disable the
> physical clear key too. I would expect setUseSoftkeys to just not
> show the T9/Clear Commands, not to disable the physical clear key
> completely ( now you just have a textfield in which you can type
> but you can't delete anything )
>
> 2. Since setSoftkeyCodes(int left, int right, int clear, int back)
> is depracted and I dont want to use the jad to set the code for the
> clear key, how can I do it with LWUITImplementation, as indicated
> in the doc ?
>
> thanks
> [Message sent by forum member 'ionutianasi' (ionutianasi)]
>
> http://forums.java.net/jive/thread.jspa?messageID=323719
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

ionutianasi
Offline
Joined: 2008-11-10
Points: 0

The issue is still there, with the LWUIT_20081222 release. Is this code correct, or am I just missing something :

Form f = new Form("");
TextField tf = new TextField();
tf.setUseSoftkeys(false);
f.addComponent(tf);
f.show();

You will end up with a textfield in which you can write but from which you can't delete ( forget about redefining the clear key; the issue is there regardless).
Looking further into the code, I realized that the keyPressed/keyReleased events are not passed to the TextField. They are consumed in the Form by the MenuBar. Since
getClearCommand returns null ( there is no explicit clear command added ), pressing the physical clear key will have no effect.

thanks

Shai Almog

OK, I see what you mean. I will try to commit a fix next week.

> The issue is still there, with the LWUIT_20081222 release. Is this
> code correct, or am I just missing something :
>
> Form f = new Form("");
> TextField tf = new TextField();
> tf.setUseSoftkeys(false);
> f.addComponent(tf);
> f.show();
>
> You will end up with a textfield in which you can write but from
> which you can't delete ( forget about redefining the clear key; the
> issue is there regardless).
> Looking further into the code, I realized that the keyPressed/
> keyReleased events are not passed to the TextField. They are
> consumed in the Form by the MenuBar. Since
> getClearCommand returns null ( there is no explicit clear command
> added ), pressing the physical clear key will have no effect.
>
> thanks
> [Message sent by forum member 'ionutianasi' (ionutianasi)]
>
> http://forums.java.net/jive/thread.jspa?messageID=323826
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

ionutianasi
Offline
Joined: 2008-11-10
Points: 0

Another issue related directly to the one above is that pressing the physical clear key will not activate the edit mode because the TextFiled will never get the key event and isEditingTrigger will never be called ( a TextField with setUseSoftkeys true or false, no matter).
Another curios thing I've noticed in isEditingTrigger is that the test against the clear key code - isClearKey(keyCode) - is not done for isQwertyInput(); now, in my case, I'm lucky because the keyCode defined in jad for the clear key is 8 and the code
if(isQwertyInput()) {
return keyCode > 0 || (Display.getInstance().getGameAction(keyCode) == Display.GAME_FIRE);
}
will make the method return true(and once the fix that will allow TextField to get the clear key events is in place , it will work), but, theoretically you could have negative clear keyCodes, no !?

thanks

Shai Almog

The issue related to the clear key is fixed in SVN for quite a while.
If it isn't working for you I assume you made some changes to text
field that broke the fix.

> Another issue related directly to the one above is that pressing
> the physical clear key will not activate the edit mode because the
> TextFiled will never get the key event and isEditingTrigger will
> never be called ( a TextField with setUseSoftkeys true or false, no
> matter).
> Another curios thing I've noticed in isEditingTrigger is that the
> test against the clear key code - isClearKey(keyCode) - is not done
> for isQwertyInput(); now, in my case, I'm lucky because the keyCode
> defined in jad for the clear key is 8 and the code
> if(isQwertyInput()) {
> return keyCode > 0 || (Display.getInstance
> ().getGameAction(keyCode) == Display.GAME_FIRE);
> }
> will make the method return true(and once the fix that will allow
> TextField to get the clear key events is in place , it will work),
> but, theoretically you could have negative clear keyCodes, no !?
>
> thanks
> [Message sent by forum member 'ionutianasi' (ionutianasi)]
>
> http://forums.java.net/jive/thread.jspa?messageID=324795
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

ionutianasi
Offline
Joined: 2008-11-10
Points: 0

Hello Shai,

I'm using the latest SVN code and the issue is still there; I'm not sure if it's the intended behavior or not but, when hitting the physical ClearKey while having focus on a TextField that is not yet in editing mode will not trigger the editing mode, nor delete a character; the event is consumed by the MenuBar and since I don't have a clear command added to the form nothing happens.

Looking at the keyReleased method in MenuBar I noticed the comment

"
// allows a back/clear command to occur regardless of whether the
// command was added to the form
"

but the code that follows makes no sense to me; it tests if the keyCode is equal to clearSK and in that case it fetches the clear Command which is null since no clear command was added and the TextField is not yet in editing mode.
Here is my code:

final Form f = new Form("test");
f.setLayout(new BorderLayout());

final TextField tf1=new TextField();
tf1.setText("bug");

f.addComponent(BorderLayout.NORTH, tf1);
f.show();

Am I doing something wrong?

thanks

anmc
Offline
Joined: 2008-10-21
Points: 0

I have a question:
If I made the the middle softkey work as back in one form( as the left softkey has a back command), I want the middle softkey to select a button instead of exiting or whatever is on the left softkey.( How to clear this command : Display.getInstance().setSoftkeyCodes(0, 0, -5, 0);
after displaying the other form?)

alesincri
Offline
Joined: 2008-05-29
Points: 0

Well, I've tried TextField in PhoneME and in J9 and HTC Windows Mobile 6.
In PhoneMe, I've got a dot when the delete keyboard-screen button is pressed with the stylus.
In J9, if I push a "j" in the keyboard-screen, i obtain "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj". That happens with all the characters.

chen

Hi,
If you would like the clear key to work as expected in TextField, you
need to specify the appropriate key code.
This can be done in the jad file, add the "SoftKey-Clear= code>" attribute or from code
Display.setSoftkeyCodes(0, 0, , 0)
Regarding the J9, this is not a LWUIT supported platform, however when
the source will be open tuning for this platform from the community is
welcome.

Regards,
Chen

lwuit-users@mobileandembedded.org wrote:
> Well, I've tried TextField in PhoneME and in J9 and HTC Windows Mobile 6.
> In PhoneMe, I've got a dot when the delete keyboard-screen button is pressed with the stylus.
> In J9, if I push a "j" in the keyboard-screen, i obtain "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj". That happens with all the characters.
> [Message sent by forum member 'alesincri' (alesincri)]
>
> http://forums.java.net/jive/thread.jspa?messageID=291533
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

alesincri
Offline
Joined: 2008-05-29
Points: 0

Indeed what i want to use is the delete keyboard-screen "button" from Windows mobile. When I click it with the stylus i obtain a dot in the screen (in phoneMe) and a rectangle (in J9).

Regards.

alesincri
Offline
Joined: 2008-05-29
Points: 0

Just to clarify, I mean the built-in screen QWERTY keyboard in Windows Mobile delete button.

Regards.

chen

Hi,
My previous response is still valid, the virtual keyboard should trigger
keycodes for java.

Chen

lwuit-users@mobileandembedded.org wrote:
> Just to clarify, I mean the built-in screen QWERTY keyboard in Windows Mobile delete button.
>
> Regards.
> [Message sent by forum member 'alesincri' (alesincri)]
>
> http://forums.java.net/jive/thread.jspa?messageID=291550
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

Shai Almog

Hi,
overriding the deleteChar method won't do what you expect. You need
to set the delete key code either by invoking Display.setSoftkeyCodes
() or by setting the JAD attribute of SoftKey-Clear to the proper key
code value.
To find out the key value you need just override Form.keyPressed and
intercept key presses to figure out the key code matching delete.

Thanks.

> When I try to delete a char into a Texfield component, I obtain a
> dot in the field, and the character isn't erased.
> I've tried to extend the TextField class and I have used deleteChar
> () with the same result.
> I use PhoneMe VM in HTC P6500.
>
> Thanks.
> [Message sent by forum member 'alesincri' (alesincri)]
>
> http://forums.java.net/jive/thread.jspa?messageID=290849
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

alesincri
Offline
Joined: 2008-05-29
Points: 0

Then, if I understand you, I can't delete characters easily using TextField. Is it in all touch screens? I think delete function is basic in a text field. With the cursor movement happens the same. Cannot I position my cursor with the stylus in the middle of the TextField?

Thanks

Shai Almog

You didn't understand.
Does the device have a hardware delete button?
If so you need to configure the keycode for that delete button, if
not use the softbutton.

Cursror positioning for touch-screen devices isn't implemented at the
moment.

> Then, if I understand you, I can't delete characters easily using
> TextField. Is it in all touch screens? I think delete function is
> basic in a text field. With the cursor movement happens the same.
> Cannot I position my cursor with the stylus in the middle of the
> TextField?
>
> Thanks
> [Message sent by forum member 'alesincri' (alesincri)]
>
> http://forums.java.net/jive/thread.jspa?messageID=290868
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]