Skip to main content

How to access to the center softbutton ? fireClicked ?

20 replies [Last post]
asterfr
Offline
Joined: 2008-07-17

Hello,

I'm trying to catch event on the center softbutton. I've tried to overwrite the fireClicked method in my container but it didn't work. Does anyone has an idea ?

Bye

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
asterfr
Offline
Joined: 2008-07-17

Thank you again Shai...

In my emulator when I clicked on this center button the code of the event isn't those stored in Display.GAME_FIRE, I looked a bit and found that I got also the same problem for the move touch (LEFT, RIGHT, UP and DOWN).

I assume that the value return by this button will change with the devices.

Shai Almog

Hi,
the event won't be GAME_FIRE. It will be some number which when
passed to Display.getInstance().getGameKey(code) would return the
GAME_FIRE value.

The same applies for up/down/left/right etc...

This is all from MIDP with some "sanitation" performed by LWUIT on
top for portability and ease.

> In my emulator when I clicked on this center button the code of the
> event isn't those stored in Display.GAME_FIRE, I looked a bit and
> found that I got also the same problem for the move touch (LEFT,
> RIGHT, UP and DOWN).
>
> I assume that the value return by this button will change with the
> devices.

Yes, that is why we need the game key method.

> [Message sent by forum member 'asterfr' (asterfr)]
>
> http://forums.java.net/jive/thread.jspa?messageID=289316

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

[att1.html]

asterfr
Offline
Joined: 2008-07-17

Good, it works... Thank you

getGameKey doesn't exist : I used game getGameAction and I suggest [b]to don't use getKeyCode[/b] for this... didn't work at all ;)

kin_ng
Offline
Joined: 2008-10-31

Hi,

I also tried to handle the fireClicked event, but the keyReleased method is not called

public void keyReleased(int code) {
if (Display.getInstance().getGameAction(code) == Display.GAME_FIRE) {
// (...)
}
}

I have a list (com.sun.lwuit.List) in a form (com.sun.lwuit.Form), and I want to select the items´ list with the fire button/ center button

thanks in advance

Shai Almog

Hi,
use addActionListener(...) on the list.

> Hi,
>
> I also tried to handle the fireClicked event, but the keyReleased
> method is not called
>
> public void keyReleased(int code) {
> if (Display.getInstance().getGameAction(code) == Display.GAME_FIRE) {
> // (...)
> }
> }
>
> I have a list (com.sun.lwuit.List) in a form (com.sun.lwuit.Form),
> and I want to select the items´ list with the fire button/ center
> button
>
> thanks in advance
> [Message sent by forum member 'kin_ng' (kin_ng)]
>
> http://forums.java.net/jive/thread.jspa?messageID=314244
>
> ---------------------------------------------------------------------
> 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]

Shai Almog

Hi,
this method only gets invoked when the 3 softbutton mode is activated
in the look and feel. We don't turn it on by default since its
impossible (to our knowledge) to detect 3 softbutton phones.

Thanks.
Shai.

> Hello,
>
> I'm trying to catch event on the center softbutton. I've tried to
> overwrite the fireClicked method in my container but it didn't
> work. Does anyone has an idea ?
>
> Bye
> [Message sent by forum member 'asterfr' (asterfr)]
>
> http://forums.java.net/jive/thread.jspa?messageID=288964
>
> ---------------------------------------------------------------------
> 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]

asterfr
Offline
Joined: 2008-07-17

Thank you Shai. So how can I access to this center button ?

Shai Almog

Middle soft button is essentially the fire key rebranded.

Thanks.

> Thank you Shai. So how can I access to this center button ?

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

[att1.html]

asterfr
Offline
Joined: 2008-07-17

Well I've a Container that display a video and i need to catch this event... How can I do that ?

Shai Almog

In this case just derive either the Form or the focused component and
override keyReleased(int code).
Use Display.getInstance().getGameKey(code) == Display.GAME_FIRE.

Thanks.

> Well I've a Container that display a video and i need to catch this
> event... How can I do that ?
> [Message sent by forum member 'asterfr' (asterfr)]
>
> http://forums.java.net/jive/thread.jspa?messageID=289054
>
> ---------------------------------------------------------------------
> 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]

Qunhuan Mei

Hello LWUIT team,

I am using Container's replace(Component old, Component new, Transition t) for page content switch. The only component of the container is a list which implements ActionListener (for testing purpose).

While the replacing is normal between two different containers, or two different lists with given transition, the problem is that after new list has replaced the old one, the actionListener in effect is always the one attached to the old component, not the new one. Thus whatever the key pressed, nothing happens to the list current visible on screen (e.g. no focus change).

I have tried all of the following:
setFocusable(...)
setFocus(...)
requestFocus()
setHandlesInput(...)
currentContainer.revalidate()

but none of them would make focus change on screen.

How can I make the system to use new container's actionListener implementation?

Many thanks,

Qunhuan

[att1.html]

chen

Hi,
The replace method just replace the component on the view, if you have
added listeners to the old Component you will have to add them again to
your new Component.

Chen

Qunhuan Mei wrote:
>
> Hello LWUIT team,
>
> I am using Container’s |*replace
> *||(Component
>
> old, Component
>
> new, Transition
>
> t) for page content switch. The only component of the container is a
> list which implements ActionListener (for testing purpose).|
>
> | |
>
> |While the replacing is normal between two different containers, or
> two different lists with given transition, the problem is that after
> new list has replaced the old one, the actionListener in effect is
> always the one attached to the old component, not the new one. Thus
> whatever the key pressed, nothing happens to the list current visible
> on screen (e.g. no focus change). |
>
> | |
>
> |I have tried all of the following: |
>
> setFocusable(...)
>
> setFocus(...)
>
> requestFocus()
>
> setHandlesInput(...)
>
> currentContainer.revalidate()
>
> but none of them would make focus change on screen.
>
> How can I make the system to use new container’s actionListener
> implementation?
>
> Many thanks,
>
> Qunhuan
>

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

Qunhuan Mei

Hi Chen,

Thank you for your quick reply.

Yes, when I create component (i.e. list), I always do addActionListener, before the list is added to the container. So, in the system, there are two implementations of the ActionListener, one added to old container, the other added to new container.

I also tried removeActionListener(..), also does not work.

Am I doing something wrong or any more clue?

Many thanks,

Qunhuan

-----Original Message-----
From: Chen.Fishbein@Sun.COM [mailto:Chen.Fishbein@Sun.COM]
Sent: 24 July 2008 16:07
To: users@lwuit.dev.java.net
Subject: Re: Action listener does not update after using Container's replace method - help please

Hi,
The replace method just replace the component on the view, if you have
added listeners to the old Component you will have to add them again to
your new Component.

Chen

Qunhuan Mei wrote:
>
> Hello LWUIT team,
>
> I am using Container's |*replace
> *||(Component
>
> old, Component
>
> new, Transition
>
> t) for page content switch. The only component of the container is a
> list which implements ActionListener (for testing purpose).|
>
> | |
>
> |While the replacing is normal between two different containers, or
> two different lists with given transition, the problem is that after
> new list has replaced the old one, the actionListener in effect is
> always the one attached to the old component, not the new one. Thus
> whatever the key pressed, nothing happens to the list current visible
> on screen (e.g. no focus change). |
>
> | |
>
> |I have tried all of the following: |
>
> setFocusable(...)
>
> setFocus(...)
>
> requestFocus()
>
> setHandlesInput(...)
>
> currentContainer.revalidate()
>
> but none of them would make focus change on screen.
>
> How can I make the system to use new container's actionListener
> implementation?
>
> Many thanks,
>
> Qunhuan
>

---------------------------------------------------------------------
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

chen

Hi,
I will have to get more info from you on this to investigate.

Chen

Qunhuan Mei wrote:
> Hi Chen,
>
> Thank you for your quick reply.
>
> Yes, when I create component (i.e. list), I always do addActionListener, before the list is added to the container. So, in the system, there are two implementations of the ActionListener, one added to old container, the other added to new container.
>
> I also tried removeActionListener(..), also does not work.
>
> Am I doing something wrong or any more clue?
>
> Many thanks,
>
> Qunhuan
>
> -----Original Message-----
> From: Chen.Fishbein@Sun.COM [mailto:Chen.Fishbein@Sun.COM]
> Sent: 24 July 2008 16:07
> To: users@lwuit.dev.java.net
> Subject: Re: Action listener does not update after using Container's replace method - help please
>
> Hi,
> The replace method just replace the component on the view, if you have
> added listeners to the old Component you will have to add them again to
> your new Component.
>
> Chen
>
> Qunhuan Mei wrote:
>
>> Hello LWUIT team,
>>
>> I am using Container's |*replace
>> *||(Component
>>
>> old, Component
>>
>> new, Transition
>>
>> t) for page content switch. The only component of the container is a
>> list which implements ActionListener (for testing purpose).|
>>
>> | |
>>
>> |While the replacing is normal between two different containers, or
>> two different lists with given transition, the problem is that after
>> new list has replaced the old one, the actionListener in effect is
>> always the one attached to the old component, not the new one. Thus
>> whatever the key pressed, nothing happens to the list current visible
>> on screen (e.g. no focus change). |
>>
>> | |
>>
>> |I have tried all of the following: |
>>
>> setFocusable(...)
>>
>> setFocus(...)
>>
>> requestFocus()
>>
>> setHandlesInput(...)
>>
>> currentContainer.revalidate()
>>
>> but none of them would make focus change on screen.
>>
>> How can I make the system to use new container's actionListener
>> implementation?
>>
>> Many thanks,
>>
>> Qunhuan
>>
>>
>
>
> ---------------------------------------------------------------------
> 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
>
>
>

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

Qunhuan Mei

Ok, I will prepare some code for you.

-----Original Message-----
From: Chen.Fishbein@Sun.COM [mailto:Chen.Fishbein@Sun.COM]
Sent: 24 July 2008 16:51
To: users@lwuit.dev.java.net
Subject: Re: Action listener does not update after using Container's replace method - help please

Hi,
I will have to get more info from you on this to investigate.

Chen

Qunhuan Mei wrote:
> Hi Chen,
>
> Thank you for your quick reply.
>
> Yes, when I create component (i.e. list), I always do addActionListener, before the list is added to the container. So, in the system, there are two implementations of the ActionListener, one added to old container, the other added to new container.
>
> I also tried removeActionListener(..), also does not work.
>
> Am I doing something wrong or any more clue?
>
> Many thanks,
>
> Qunhuan
>
> -----Original Message-----
> From: Chen.Fishbein@Sun.COM [mailto:Chen.Fishbein@Sun.COM]
> Sent: 24 July 2008 16:07
> To: users@lwuit.dev.java.net
> Subject: Re: Action listener does not update after using Container's replace method - help please
>
> Hi,
> The replace method just replace the component on the view, if you have
> added listeners to the old Component you will have to add them again to
> your new Component.
>
> Chen
>
> Qunhuan Mei wrote:
>
>> Hello LWUIT team,
>>
>> I am using Container's |*replace
>> *||(Component
>>
>> old, Component
>>
>> new, Transition
>>
>> t) for page content switch. The only component of the container is a
>> list which implements ActionListener (for testing purpose).|
>>
>> | |
>>
>> |While the replacing is normal between two different containers, or
>> two different lists with given transition, the problem is that after
>> new list has replaced the old one, the actionListener in effect is
>> always the one attached to the old component, not the new one. Thus
>> whatever the key pressed, nothing happens to the list current visible
>> on screen (e.g. no focus change). |
>>
>> | |
>>
>> |I have tried all of the following: |
>>
>> setFocusable(...)
>>
>> setFocus(...)
>>
>> requestFocus()
>>
>> setHandlesInput(...)
>>
>> currentContainer.revalidate()
>>
>> but none of them would make focus change on screen.
>>
>> How can I make the system to use new container's actionListener
>> implementation?
>>
>> Many thanks,
>>
>> Qunhuan
>>
>>
>
>
> ---------------------------------------------------------------------
> 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
>
>
>

---------------------------------------------------------------------
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

Qunhuan Mei

Hi again,

The addCommand(Command cmd, int offset) appears to function the same as addCommand(Command cmd). The command failed to appear at the given offset place.

Is it a known problem?

Thanks,

Qunhuan

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

Shai Almog

Hi,
its known now...

Thanks.

> Hi again,
>
> The addCommand(Command cmd, int offset) appears to function the
> same as addCommand(Command cmd). The command failed to appear at
> the given offset place.
>
> Is it a known problem?
>
> Thanks,
>
> Qunhuan
>
>
> ---------------------------------------------------------------------
> 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 Shai,
great job! The latest drop solved the few problems I had in past. So I am not sure if I am incompetent or the bug still exists.
My code:
public void startApp()
{
Display.init(this);

Form f = new Form("CommandTest");
f.show();

f.addCommand(new Command("Commend1"));
f.addCommand(new Command("Command2"));
f.addCommand(new Command("Command3"));
f.addCommand(new Command("C offset"), 0);
}

Thanks,
danko

Shai Almog

Hi Danko,
you are correct the bug was fixed incorrectly. Just committed a new
fix to SVN so you can update and check it.

> Hi Shai,
> great job! The latest drop solved the few problems I had in past.
> So I am not sure if I am incompetent or the bug still exists.
> My code:
> public void startApp()
> {
> Display.init(this);
>
> Form f = new Form("CommandTest");
> f.show();
>
> f.addCommand(new Command("Commend1"));
> f.addCommand(new Command("Command2"));
> f.addCommand(new Command("Command3"));
> f.addCommand(new Command("C offset"), 0);
> }
>
> Thanks,
> danko
> [Message sent by forum member 'danko' (danko)]
>
> http://forums.java.net/jive/thread.jspa?messageID=293441
>
> ---------------------------------------------------------------------
> 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 Shai,
I checked out the SVN and now it works correct. Receive bug fixes so fast is really great!

Thanks,
danko