Skip to main content

de-link channel up/ channel down keys from an ocap application

3 replies [Last post]
rmninocap
Offline
Joined: 2010-06-06

Hi,

I wrote an application with just one component a HTextButton.

The channel up / down keys get locked as soon as i do a requestFocus() on that button. At the same time Volume UP/down keys work fine.

Tried using UserEventListener and added only Nav keys + enter key. This was tested on the ADB 7822C developer STB
.
Has anyone faced this issue.....???

Regards
RMN

Reply viewing options

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

Can you provide your test application so that we can attempt to reproduce it? The source files and the accompanying hostapp.properties file would be useful. If they are small enough, you can just copy them inline in a forum post. Otherwise, feel free to create an IssueTracker issue and you can attach multiple files to the issue itself.

G

rmninocap
Offline
Joined: 2010-06-06

Hi,

PFB the code, If we uncomment the line testButton.requestFocus(), the channel up/down gets locked.

package org.ocapproject.xlet;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.security.Key;

import javax.tv.xlet.Xlet;
import javax.tv.xlet.XletStateChangeException;

import org.dvb.event.UserEvent;
import org.dvb.event.UserEventListener;
import org.dvb.event.UserEventRepository;
import org.havi.ui.HContainer;
import org.havi.ui.HScene;
import org.havi.ui.HSceneFactory;
import org.havi.ui.HSceneTemplate;
import org.havi.ui.HTextButton;
import org.havi.ui.HVisible;
import org.havi.ui.event.HRcEvent;
import org.ocap.event.EventManager;

/**
* The class presents a simple Xlet example for writing an OCAP application.
*
* @author Cable Television Laboratories, Inc.
*/
public class SimpleXlet extends HContainer implements Xlet, FocusListener
{
/**
*
*/
private static final long serialVersionUID = 1L;
// A flag indicating that the Xlet has been started.
private boolean m_started = false;
private HScene hScene = null;
private HTextButton testButton = null;
UserEventListener userEventListener = null;

UserEventRepository userEvents = new UserEventRepository("channel-events");

/**
* The default constructor.
*/
public SimpleXlet()
{
// Does nothing extra.

}

/**
* Initializes the OCAP Xlet.
*

* A reference to the context is stored for further need.
* This is the place where any initialisation should be done,
* unless it takes a lot of time or resources.
*

*
* @param The context for this Xlet is passed in.
*
* @throws XletStateChangeException If something goes wrong, then an
* XletStateChangeException is sent so that the runtime system knows that
* the Xlet can't be initialised.
*/
public void initXlet(javax.tv.xlet.XletContext ctx) throws javax.tv.xlet.XletStateChangeException
{
try
{
System.out.println("in init xlet");
hScene = getResources();
// userEventListener.
userEvents.addAllNumericKeys();
userEvents.addAllColourKeys();
userEvents.addAllArrowKeys();
userEvents.addKey(HRcEvent.VK_ENTER);
userEventListener = new UserEventListener(){
public void userEventReceived(UserEvent ue) {
System.out.println("inside userevent listner"+ue.getCode());
if(ue.getCode()==HRcEvent.VK_UP){
testButton.requestFocus();
}
if(ue.getCode()==HRcEvent.VK_DOWN){
testButton.setFocusable(false);
}
}
};
EventManager.getInstance().addUserEventListener(userEventListener, userEvents);
// userEvents.removeKey(HRcEvent.VK_CHANNEL_UP);

// XXX - Do something here, like initializing application.
} catch (Exception ex)
{
ex.printStackTrace();
throw new javax.tv.xlet.XletStateChangeException(ex.getMessage());
}
}

/**
* Starts the OCAP Xlet.
*
* @throws XletStateChangeException If something goes wrong, then an
* XletStateChangeException is sent so that the runtime system knows that
* the Xlet can't be started.
*/
public void startXlet() throws javax.tv.xlet.XletStateChangeException
{

System.out.println("Inside start Xlt");
testButton = new HTextButton("Click here");
testButton.setBounds(100, 100, 40, 18);
testButton.setBackgroundMode(HVisible.BACKGROUND_FILL);
testButton.setBackground(Color.gray);
testButton.setForeground(Color.black);
testButton.setFont(new Font("Arial", Font.PLAIN, 12));
testButton.setVerticalAlignment(HVisible.VALIGN_CENTER);
testButton.setHorizontalAlignment(HVisible.HALIGN_LEFT);
testButton.addFocusListener(this);
// testButton.addKeyListener(this);
hScene.add(testButton);
hScene.setVisible(true);
// testButton.requestFocus();

}

/**
* Pauses the OCAP Xlet.
*/
public void pauseXlet()
{
if (m_started)
{
// XXX - Do something here, like hiding the application.
}
}

/**
* Destroys the OCAP Xlet.
*
* @throws XletStateChangeException If something goes wrong, then an
* XletStateChangeException is sent so that the runtime system knows that
* the Xlet can't be destroyed.
*/
public void destroyXlet(boolean forced) throws javax.tv.xlet.XletStateChangeException
{
try
{
if (m_started)
{
// XXX - Do something here, like disposing the application
// resources.
m_started = false;
}
} catch (Exception ex)
{
ex.printStackTrace();
throw new javax.tv.xlet.XletStateChangeException(ex.getMessage());
}
}

public HScene getResources() {
System.out.println("in scene xlet .............");
HSceneFactory factory = HSceneFactory.getInstance();

HSceneTemplate hst = new HSceneTemplate();

hst.setPreference(HSceneTemplate.SCENE_SCREEN_DIMENSION, new org.havi.ui.HScreenDimension(1,1), HSceneTemplate.REQUIRED);
hst.setPreference(HSceneTemplate.SCENE_SCREEN_LOCATION, new org.havi.ui.HScreenPoint(0,0), HSceneTemplate.REQUIRED);

HScene hscene = factory.getBestScene(hst);
return hscene;
}

public void keyPressed(KeyEvent keyEvent) {
// TODO Auto-generated method stub
}

public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub

}

public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub

}

public void focusGained(FocusEvent focusEvent) {
// TODO Auto-generated method stub
if(focusEvent.getSource() == testButton){
System.out.println("Inside focus gained");
testButton.setBackground(Color.yellow);
}
}

public void focusLost(FocusEvent arg0) {
// TODO Auto-generated method stub

}

}

Regards
RMN

greg80303
Offline
Joined: 2008-07-03

FYI -- our forums try to interpret < > characters as HTML, so thats why your sample app shows up as a big wall of text. Regardless, thank you for the test. I will try to reproduce this problem with your sample. If I can see the same problem, I will post in this thread and ask you to create an IssueTracker issue and attach this sample app. That way, we can track the fix and make sure that it gets into the trunk repository.

G