views:

328

answers:

1

Hello, I'm trying to build a context sensitive based command list. I set the command.ITEM option for all my command buttons. But I couldn't find a way how to provide the following functionality:

I have a list of values say A, B,C For A, my command menu should contain 2,4 When I move the selection (cursor) to B, my commands menu should have 1,3 When I move to C, commands should have 2,1 Again when I move back to A, it should have A's command menu (2,4)

It can be used for a list of files and directories:

When a file is selected, I want to show options (commands) open, edit and delete. When I select a directory, I want to show commands just open and delete.

Thanks in advance for any help pointing to the right direction.

A: 

The specification for the javax.microedition.lcdui.Form class (Which I assume is what you're using) states:

"These traversing and scrolling operations do not cause application-visible events"

There is also no method called before the command menu gets displayed.

All this means that you can't do what you want here using a Form.

Depending on the J2ME implementation on the specific phone you're targetting, javax.microedition.lcdui.CustomItem.getInteractionModes() might tell you whether you can use a single CustomItem in your form to create a context-sensitive menu.

The only sure way to do this on all phones is to use a javax.microedition.lcdui.Canvas and re-implement the controls you need by drawing them yourself. You can then keep track of which one is "selected" and populate your own command menu before displaying it in response to low-level keyPressed() events.

You might want to look into the LWUIT open source library for an intermediary solution.

QuickRecipesOnSymbianOS