Skip to main content

Softbutton KeyCode

3 replies [Last post]
danko
Offline
Joined: 2008-07-18

Hi,
my intention is to delete with a long click on softbutton the whole text of a textfield.
So I need to get the keyCode of the softbutton. I have seen that the codes are different but the LWUIT API sets them in setKnownSoftKeyCodes() to static fields.
Do I have access in any way like setKnownSoftKeyCodes() to that fields?

Thanks,
danko

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi,
while we can theoretically expose this keycode it won't work as you
expect since we block the softkey codes from trickling down in the
key pressed/released hierarchy and they will never be delivered to
your form/component. The reasoning is both architectural (softkeys
are an implementation detail) and technical (we don't want to handle
key code events twice).
You can grab the keycode by replacing the Implementation class a
functionality which will be possible without code changes (package
protected) after my next commit. I still won't recommend doing this
since this is a seriously heavy hack.

> Hi,
> my intention is to delete with a long click on softbutton the whole
> text of a textfield.
> So I need to get the keyCode of the softbutton. I have seen that
> the codes are different but the LWUIT API sets them in
> setKnownSoftKeyCodes() to static fields.
> Do I have access in any way like setKnownSoftKeyCodes() to that
> fields?
>
> Thanks,
> danko
> [Message sent by forum member 'danko' (danko)]
>
> http://forums.java.net/jive/thread.jspa?messageID=300241
>
> ---------------------------------------------------------------------
> 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]

danko
Offline
Joined: 2008-07-18

Hi,
I use the latest SVN version of LWUIT and have that in my code
private class MyDialog extends Dialog
{

public void keyRepeated(int keyCode)
{
System.out.println("keyRepeated");
}

public void keyPressed(int keyCode)
{
System.out.println("keyPressed");
}
....
and I get both printouts by pressing any softbutton.

I do not like to do that seriously heavy hack for that simple feature. ;)
Do you think to implement an easier way to get that feature in a future version of LWUIT? It is not an exotic feature. A lot of mobile phone have that behavior to delete the whole text of textfield/area. So I think other programmers will have the same need.

Thanks,
danko

Shai Almog

Hi,
delete a text using a long click on the softbuttons seems like a
reasonable use case. Since TextField is package protected it should
have access to these keycodes anyway, feel free to file an RFE in our
issue tracking system and I will get to it when I can.

> Hi,
> I use the latest SVN version of LWUIT and have that in my code
> private class MyDialog extends Dialog
> {
>
> public void keyRepeated(int keyCode)
> {
> System.out.println("keyRepeated");
> }
>
> public void keyPressed(int keyCode)
> {
> System.out.println("keyPressed");
> }
> ....
> and I get both printouts by pressing any softbutton.
>
> I do not like to do that seriously heavy hack for that simple
> feature. ;)
> Do you think to implement an easier way to get that feature in a
> future version of LWUIT? It is not an exotic feature. A lot of
> mobile phone have that behavior to delete the whole text of
> textfield/area. So I think other programmers will have the same need.
>
> Thanks,
> danko
> [Message sent by forum member 'danko' (danko)]
>
> http://forums.java.net/jive/thread.jspa?messageID=300314
>
> ---------------------------------------------------------------------
> 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]