Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 22
Registered: ‎10-30-2008
My Device: Not Specified
Accepted Solution

Storm - How can MIDP Canvas capture Screeen.touchEvent(TouchEvent message)?

[ Edited ]

Hello all,

 

I have been trying to capture TouchEvent.CLICK with an app that uses MIDP Canvas: aka end-user pressing the touchscreen - notice I'm referring to the same "click" that happens when user selects "Browser" icon in main screen and pushes down the whole screen to make it click.

 

I can receive and process all MIDP pointer-events perfectly (pointerPressed, pointerReleased and pointerDragged).

 

In the past, we were able to capture special keys using the following:

 

class AppCanvas extends Canvas implemens  TrackwheelListener, KeyListener {

public AppCanvas() {

...

if (Ui.getUiEngine().getActiveScreen() != null) {
            Ui.getUiEngine().getActiveScreen().addTrackwheelListener(this);
            Ui.getUiEngine().getActiveScreen().addKeyListener(this);
        }
 }

 

public boolean touchEvent(TouchEvent msg) {

// never gets called

...

}

 

Canvas.keyPressed and keyReleased would get some keys whereas the Listeners TrackwheelListener and KeyListener would get the others.

 

However, it seems like there is no way for receiving Screen.touchEvent(TouchEvent message) unless you extend Screen class which is something we are not planning on doing - since our app uses MIDP Canvas.

 

Here is the main problem in terms of feeling of native BB app and midlet:

 

A Storm end-user would expect that touching a UI widget will assign focus to it but that would NOT fire the action of that widget. Instead, the end-user would expect that the action of that widget would fire when the widget is "clicked".

Obviously, there is no way to tell a "touch" from a "clicked" using MIDP Canvas pointer-events.

 

Any suggestions?

 

Message Edited by hpedroza on 10-31-2008 10:43 AM
Developer
Posts: 22
Registered: ‎10-30-2008
My Device: Not Specified

Re: Storm - How can MIDP Canvas capture Screeen.touchEvent(TouchEvent message)?

For rapc-compiling, I'm using net_rim_api.jar that came with JDE 4.7.0-beta.

 

I'm using real phone Storm 9530 for Verizon:

v4.7.0.51 (platform 4.0.0.59)

 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Storm - How can MIDP Canvas capture Screeen.touchEvent(TouchEvent message)?

Note that the KeyListener and TrackwheelListener are not designed to be used by or supported by MIDlets.  They are designed for BlackBerry CLDC applications.

 

You can use the BlackBerryCanvas to capture touch events in a MIDlet.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 22
Registered: ‎10-30-2008
My Device: Not Specified

Re: Storm - How can MIDP Canvas capture Screeen.touchEvent(TouchEvent message)?

Thank you

 

I just came to know about BlackBerryCanvas from this thread:

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=8345

 

Why would a Midlet had problems using TrackwheelListener?