Skip to main content

HSinglelineEntry on Sony PlayStation 3

4 replies [Last post]
zohan29
Offline
Joined: 2009-12-20
Points: 0

Hi,

I can't make HSinglelineEntry work on a PS3. It renders OK, gets focus and responds to the Enter key by toggling focus, allows caret to be moved by arrow keys. But neither it responds to numeric keys, nor does HKeyListener instance receive VK_ENTER event.

=====

import java.awt.Font;
import java.awt.event.KeyEvent;
import javax.tv.xlet.Xlet;
import javax.tv.xlet.XletContext;
import javax.tv.xlet.XletStateChangeException;
import org.havi.ui.HKeyboardInputPreferred;
import org.havi.ui.HScene;
import org.havi.ui.HSceneFactory;
import org.havi.ui.HSinglelineEntry;
import org.havi.ui.HState;
import org.havi.ui.event.HKeyListener;

public class FooXlet implements Xlet {

private HScene scene;
private HSinglelineEntry input;

public void initXlet(XletContext xc) throws XletStateChangeException {
}

public void startXlet() throws XletStateChangeException {

scene = HSceneFactory.getInstance().getDefaultHScene();
scene.setLayout(null);

Font font = new Font(null, Font.PLAIN, 48);

input = new HSinglelineEntry();
input.setBounds(0, 0, 300, 80);
input.setFont(font);
input.setMaxChars(4);
input.setTextContent("123", HState.ALL_STATES);
input.setType(HKeyboardInputPreferred.INPUT_NUMERIC); // INPUT_ANY does not work either

input.addHKeyListener(new HKeyListener() {

public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
String text = input.getTextContent(HState.NORMAL_STATE);
// do something
}
}
public void keyTyped(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
}
});

scene.add(input);
scene.validate();
scene.setVisible(true);
input.setVisible(true);
input.setEditMode(true);
input.requestFocus();

}

public void pauseXlet() {
}

public void destroyXlet(boolean bln) throws XletStateChangeException {
}

}

=====

The same code works pretty well in Scenarist QC. I wonder maybe this is a known PS3 bug?

Thanks!
Zohan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
zohan29
Offline
Joined: 2009-12-20
Points: 0

It suddenly came to my mind, do we need some manipulations with EventManager?

More generally, what's the default way of handling RC events (namely, number keys) - do HAVi widgets get "subscribed" to them out-of-the box?

Thx,
Zohan

Gunnar Adler

Try creating a new org.dvb.event.UserEventRepository, then add the
keys you need and have org.dvb.event.EventManager add a class
implementing org.dvb.event.UserEventListener as a new listener, e.g.
your Xlet. This class will receive events for the registered keys...

---------------------------------------------------------------------
To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net

zohan29
Offline
Joined: 2009-12-20
Points: 0

Gunnar, thank your for your answer,

Yes, this approach is fairly straight-forward and clear, but my intention is to make HSinglelineEntry (standard HAVi widget) receive events. With EventManager approach, I guess I will have to convert UserEvent instances to HKeyEvent ones and pass it to HSinglelineEntry manually, right?

zohan29
Offline
Joined: 2009-12-20
Points: 0

I've tried constructing and passing HKeyEvent to HSinglelineEntry manually (by processEvent), with no result. Seems like it is being ignored silently. I've checked that HSinglelineEntry is enabled, focused, and is in editable state, and event mask is set to KEY_EVENT_MASK | TEXT_EVENT_MASK | ACTION_EVENT_MASK.

Seems like HSinglelineEntry is simply not implemented properly in PS3, though it is hard to believe that HAVI's proponent's product can be THAT buggy :(