Form切换回Canvas后,左右软件键不能捕获,请问如何解决?
class MyForm extends Form implements CommandListener{
public MyForm()
{
super("Form");
StringItem stritem = new StringItem(null,"myform") ;
this.append(stritem) ;
cmdback = new Command("返回",Command.BACK,1);
this.addCommand(cmdback) ;
this.setCommandListener(this);
}
public void commandAction( Command c , Displayable s ) {
if( c == cmdback ) {
//切换到canvas
}
}
class MyCanvas extends Canvas{
int key_code =0;
public MyCanvas( )
{
}
public void paint(Graphics g)
{
g.drawString(Integer.toString(key_code), 30,30,Graphics.TOP | Graphics.RIGHT) ;
}
protected void keyReleased(int keyCode )
{
key_code=keyCode ;
repaint();
}
}
切回Canvas后,按左右软件键、中键无反应,上下键能捕获。
在WTK摸拟器上切换后能捕获,但在nokia真机上出现上述情况,请各位高手分析一下,谢谢!
------解决方案--------------------
切换Canvas的时候,记得设置Canvas为全屏模式