×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Jan 2004
    Posts
    125

    eSWT + Command (for menu)

    Hi,

    I perhaps miss something but in eSWT, I create Menu using Command widget (not menubar and menuitem)... Do you know how to create a separator with the command widget ?

    Thanks

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: eSWT + Command (for menu)

    Hi frasene,

    Can you share the UI code so that I can see how your Menu looks like? Do you need vertical or horizontal separators?

  3. #3
    Regular Contributor
    Join Date
    Jan 2004
    Posts
    125

    Re: eSWT + Command (for menu)

    Hi,

    Imagine this code :

    ---------------------------------------------------------------------------------------

    package ihm.menu;

    import ihm.general.INavigation;
    import ihm.general.Library;

    import org.eclipse.ercp.swt.mobile.Command;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.events.SelectionListener;
    import org.eclipse.swt.widgets.Shell;

    public class MenuDEF implements SelectionListener {

    private Command cmdEXI;
    private Command cmdINF;
    private Command cmdPEC;
    private INavigation cmd;

    public MenuDEF(Shell ecr, INavigation cmd) {
    this.cmd = cmd;
    creerCMD(ecr);
    }

    private Command creerOPT(Command groupe, String texte, int typ, SelectionListener obj) {
    Command opt = new Command(groupe, typ, 0);
    opt.setText(texte);
    opt.addSelectionListener(obj);
    return opt;
    }

    private void creerCMD(Shell shell) {
    cmdEXI = creerOPT(shell, "Exit", Command.EXIT, this);
    cmdPEC = creerOPT(shell, "Fullscreen", Command.SELECT, this);
    cmdINF = creerOPT(shell, "About", Command.SELECT, this);
    }

    public void widgetDefaultSelected(SelectionEvent e) {
    }

    public void widgetSelected(SelectionEvent e) {
    try {
    if (e.widget.equals(cmdEXI)) {
    cmd.exit();
    } else if (e.widget.equals(cmdINF)) {
    cmd.about();
    } else if (e.widget.equals(cmdPEC)) {
    Library.fullScreen(true);
    }
    } catch (Exception ex) {
    Librairie.debug("MenuDEF", "widgetSelected", ex);
    }
    }
    }

    ---------------------------------------------------------------------------------------

    So in this case I have EXIT on the left and FULLSCREEN + ABOUT on the right.

    For instance, I will be interested to add an horizontal separator between FULLSCREEN and ABOUT ?

    I can put obviously a disabled Command with a text like ------------------ .

    But is there an existing solution included into eSWT ?

    Thanks
    Last edited by frasene; 2011-12-15 at 13:54.

  4. #4
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: eSWT + Command (for menu)

    Hi frasene and apologies for the delay,

    What you are looking for is the SEPARATOR style which is available for MenuItem but not for Command widgets. While many eSWT widgets are constructed by providing as argument a supporting style, not all styles are relevant for every widget. Command widgets in eSWT are constructed only by the following arguments: their parent, their type and priority. In other words, you cannot set a SEPARATOR style to a Command widget. You will have to use a Menu widget and attach a MenuItem with SEPARATOR style.

    I assume that you are already familiar with eSWT's Java Documentation, but in case you haven't looked at it yet, you can find in it, the supported styles for each widget.
    For example for MenuItem objects you can find more details here:
    http://library.developer.nokia.com/t.../MenuItem.html

    A Summary of all classes can be found here:
    http://library.developer.nokia.com/t...w-summary.html
    Last edited by skalogir; 2011-12-29 at 21:08.

  5. #5
    Regular Contributor
    Join Date
    Jan 2004
    Posts
    125

    Re: eSWT + Command (for menu)

    Hi,

    As you said and according to the api, it is not possible to have separator with Command... You can just add a command with a text like "...". The command must be enabled to be displayed in the menu.

    Thanks

  6. #6
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: eSWT + Command (for menu)

    That's also a solution, though it might not be optimal, because the number of dots required to cover the entire length of the command might depend on the command's size which in turn might depend on the screen's size. So there is a risk that the visual result is different on different devices/platforms. Make sure that you test your application if you plan on deploying it on multiple devices.

Similar Threads

  1. Command Menu
    By arvind kumar yadav in forum Mobile Java General
    Replies: 2
    Last Post: 2010-12-01, 07:41
  2. Display Command Menu
    By sherry_tsk in forum Mobile Java General
    Replies: 4
    Last Post: 2007-07-20, 03:14
  3. Set Menu Command name in Arabic?
    By chishti.hameed in forum Symbian User Interface
    Replies: 4
    Last Post: 2005-06-24, 13:04
  4. Is there away to make the Command menu pop up?
    By Woody_FX in forum Mobile Java General
    Replies: 0
    Last Post: 2003-11-21, 23:17
  5. menu command using J2ME
    By vchhaochharia in forum Mobile Java General
    Replies: 0
    Last Post: 2002-02-27, 06:45

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •