CommandAction for Command.OK w/o the send key

R

RJH

Hi all,

I've got a question that I cant seem to figure out from searching
and that is: I am using a canvas and adding commands to that canvas
for certain actions, namely that of Command.OK to select an option. It
works fine, but the problem I am coming across is that CommandAction
is being entered with Command.OK as it command both when the OK key as
well as the Send Key is pressed. Is there a way to disable the send
key so that it does not fire off the Command.OK or even check to see
which key was pressed inside the CommandAction, so that I can
disregard it?

Thank you so much in advance.
 
H

hitdingcn

Hi all,

I've got a question that I cant seem to figure out from searching
and that is: I am using a canvas and adding commands to that canvas
for certain actions, namely that of Command.OK to select an option. It
works fine, but the problem I am coming across is that CommandAction
is being entered with Command.OK as it command both when the OK key as
well as the Send Key is pressed. Is there a way to disable the send
key so that it does not fire off the Command.OK or even check to see
which key was pressed inside the CommandAction, so that I can
disregard it?

Thank you so much in advance.

To see if the Send Key button is the same type of OK Key.If they are
the same type, in CommandAction the event will trigger the Command.OK.
 
P

piazzamvp

But I dont want it to do my logic if the Send key is pressed. I want a
way of distinguishing which key they pressed to get Command.OK to be
sent.
 
A

Andrew Thompson

RJH wrote:
...
I've got a question that I cant seem to figure out from searching
and that is: I am using a canvas ..

Why a Canvas? Drawing can be done directly on
a Panel or JPanel. I have never found much use
for Canvas.

Why AWT, rather than Swing? AWT is fine for
some things, but Swing has a much richer set of
GUI components.
..and adding commands ...

What do you mean by that?
...to that canvas
for certain actions, namely that of Command.

Huh? That means nothing to me.
..OK to select an option. It
works fine, but the problem I am coming across is that CommandAction
is being entered with Command.OK as it command both when the OK key as
well as the Send Key is pressed. Is there a way to disable the send
key so that it does not fire off the Command.OK or even check to see
which key was pressed inside the CommandAction, so that I can
disregard it?

I had a dozen more questions that popped up while
reading the rest of that. But then I realised, they
would all be explained by an SSCCE.
<http://www.physci.org/codes/sscce.html>

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200705/1
 
P

piazzamvp

Ok.

CommandAction is triggered with Commands that I add. I have added a
Command for when the OK key is pressed
namely: Command appendCommand = new Command( "Random", Command.OK,
0 );
Then I add the command to the canvas:
addCommand( appendCommand );
Then whenever that option is selected it fires off Command.OK to the
CommandAction function

However on some phones, (im not sure if others are the same way) that
Command.OK is fired off not only when the OK key is pressed, but also
when the Send Key is pressed. The Send key on this particular phone is
keycode -11 and the middle softkey is -23, but they both trigger it.
In the CommandAction function I am looking for a way to distinguish
which way button they used to get it to come in.

I am able to check the keycode in the keypress function for
everything else, but in the canvas it uses those commands.
 
P

piazzamvp

basically i need to do this:

Command enterGame = new Command( "Game", Command.OK, 0 );
GameCanvas.addCommand(enterGame);

public void commandAction( Command c, Displayable d )
{
//check if the commandAction event is triggered by enterGame
if( c == enterGame)
{
// check which button they used to get it to trigger
//if(send key was pressed)
return;
//else
enterState(game);
}
}
 
P

piazzamvp

actually i'm not sure why I stated Canvas, its using a Form that I
have a problem with
 
P

piazzamvp

I've just recently read that it is impossible to detect key presses
within a form.
So now what I would like to do is disable the send key from having any
function in Forms, so that it never calls CommandAction with the
Command.SCREEN or Command.OK command type.
 
P

piazzamvp

I've just recently read that it is impossible to detect key presses
within a form.
So now what I would like to do is disable the send key from having any
function in Forms, so that it never calls CommandAction with the
Command.SCREEN or Command.OK command type.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top