Describe the bug
Attaching a bluetooth keyboard doesn't work well. There is no "keyListener" type interface,
and if you override the KeyPress and KeyRelease methods on class Form, you'll see that
the available data is not consistent or useful.
On IOS, there are no KeyPress or KeyRelease calls at all.
On Android, ordinary characters work, but a lot of characters generate calls with a keycode of 0
and some keys that ought to be reprented (like the "enter" key) generate nothing.
On the simulator (using the real keyboard), space and enter both generate the same -90 keycode, and the function
keys generate nothing.
try this test program
''''java
package com.boardspace.dtest;
import java.io.IOException;
import java.io.InputStream;
import com.codename1.media.MediaManager;
import com.codename1.ui.Component;
// issue #2567
// this version shows that g.rotate interacts badly with clipping
//
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.Label;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.events.ActionListener;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.ui.Graphics;
import com.codename1.ui.layouts.BorderLayout;
class Dform extends Form
{ public Dform(String m) { super(m); }
public void keyPressed(int keycode)
{
Dtest.keyMessage = "pressed "+keycode;
repaint();
super.keyPressed(keycode);;
}
public void keyReleased(int keycode)
{
Dtest.keyMessage = "released "+keycode;
repaint();
super.keyReleased(keycode);;
}
}
public class Dtest implements ActionListener
{
private Form current;
@SuppressWarnings("unused")
private Resources theme;
public void init(Object context) {
theme = UIManager.initFirstTheme("/theme");
}
public int loops = 0;
public String errorMessage;
public static String keyMessage = "none yet";
public void start() {
if(current != null){
current.show();
return;
}
Form hi = new Dform("Hi >>0 World");
current = hi;
hi.setLayout(new BorderLayout());
hi.addComponent(BorderLayout.CENTER, new Label("Hi Overlay World 2") {
@Override
public void paint(Graphics g) {
//g.resetAffine();
int w = getWidth();
int h = getHeight();
g.setColor(0x8f8f9f7f);
g.fillRect(0,0,w,h);
g.setColor(0xff);
g.drawString(keyMessage,w/4,h/2);
if(errorMessage!=null) { g.drawString(errorMessage,w/4,h/2+30); }
}
});
hi.show();
Runnable rr = new Runnable (){
public void run() {
System.out.println("running");
while(true)
{
try { Thread.sleep(20); }
catch (InterruptedException e) { };
}}
};
new Thread(rr).start();
}
public void stop() {
current = Display.getInstance().getCurrent();
}
public void destroy() {
}
@OverRide
public void actionPerformed(ActionEvent evt) {
// TODO Auto-generated method stub
}
}
''''
Describe the bug
Attaching a bluetooth keyboard doesn't work well. There is no "keyListener" type interface,
and if you override the KeyPress and KeyRelease methods on class Form, you'll see that
the available data is not consistent or useful.
On IOS, there are no KeyPress or KeyRelease calls at all.
On Android, ordinary characters work, but a lot of characters generate calls with a keycode of 0
and some keys that ought to be reprented (like the "enter" key) generate nothing.
On the simulator (using the real keyboard), space and enter both generate the same -90 keycode, and the function
keys generate nothing.
try this test program
''''java
package com.boardspace.dtest;
import java.io.IOException;
import java.io.InputStream;
import com.codename1.media.MediaManager;
import com.codename1.ui.Component;
// issue #2567
// this version shows that g.rotate interacts badly with clipping
//
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.Label;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.events.ActionListener;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.ui.Graphics;
import com.codename1.ui.layouts.BorderLayout;
class Dform extends Form
{ public Dform(String m) { super(m); }
public void keyPressed(int keycode)
{
Dtest.keyMessage = "pressed "+keycode;
repaint();
super.keyPressed(keycode);;
}
public void keyReleased(int keycode)
{
Dtest.keyMessage = "released "+keycode;
repaint();
super.keyReleased(keycode);;
}
}
public class Dtest implements ActionListener
{
private Form current;
@SuppressWarnings("unused")
private Resources theme;
public void init(Object context) {
theme = UIManager.initFirstTheme("/theme");
}
public int loops = 0;
public String errorMessage;
public static String keyMessage = "none yet";
public void start() {
if(current != null){
current.show();
return;
}
Form hi = new Dform("Hi >>0 World");
current = hi;
hi.setLayout(new BorderLayout());
hi.addComponent(BorderLayout.CENTER, new Label("Hi Overlay World 2") {
}
public void stop() {
current = Display.getInstance().getCurrent();
}
public void destroy() {
}
@OverRide
public void actionPerformed(ActionEvent evt) {
// TODO Auto-generated method stub
}
}
''''