Meaningless Drivel is fun!*
The moose likes Java Micro Edition and the fly likes Mouse support in J2ME? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Mouse support in J2ME?" Watch "Mouse support in J2ME?" New topic
Author

Mouse support in J2ME?

Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
A couple of years ago I played with writing a Java app for my Palm IIIx and one of the useful things was being able to detect the equivalent of mouseDown, mouseMove, and mouseUp events.
Is there support for such things in MIDP 2.0?


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Jonathan Knudsen
Author
Ranch Hand

Joined: Apr 22, 2003
Posts: 55
MIDP 1.0 supports pointer events, but it depends on the device. Most cell phones don't have touch screens, but there are a few exceptions: Palm OS devices, Sony Ericsson P800, possibly others.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Jonathan Knudsen:
MIDP 1.0 supports pointer events, but it depends on the device.

What would be the preferred way and location for testing whether a pointer is available/supported by the handheld? Will this change with MIDP 2.0?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Is there some idiomatic equivalent on a cell phone that doesn't have a touch-sensitive screen?
Jonathan Knudsen
Author
Ranch Hand

Joined: Apr 22, 2003
Posts: 55
You can find out whether pointer events are supported by calling the hasPointerEvents() and hasMotionPointerEvents() in the Canvas class. If these are supported, then your Canvas subclass will be notified via the pointerPressed(), pointerReleased(), and pointerDragged() methods in Canvas.
If pointer events are crucial to your application but not supported on the device, you will need to provide an alternate method of input, probably based on keys.
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Jonathan,
Thanks for the quick response. I appreciate it.
If I don't win a copy of your book, I'll probably have to go out and buy one.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mouse support in J2ME?