×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    280

    Simple Yes-No-Dialog in LWUIT Asha501

    Hello developers,

    I want to ask the user for confirmation before deleting something. I tried the following code:

    Code:
            boolean confirmed = Dialog.show(
                    "Confirmation", 
                    "Do you really want to delete the high score?", 
                    "Yes", 
                    "No");
            if (confirmed){
               ...                     
            }
    This works, but it has two issues: ( with LWUIT 1.0.5 an Asha 501)

    1) It looks bad, because there is a white textbox inside the black-dimmed dialog background. see attached picture of confirmation dialog.
    lwuit-cornfimdialog-asha.png

    2) The back key is not handled by the dialog. when the user uses the back key, the user sees app-close-dialog. Instead back key should be handled like pessing the "No" button.

    Is there a way to create a simple dialog which looks native and also handles the back-key?

    Regards

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: Simple Yes-No-Dialog in LWUIT Asha501

    While I have no experience with LWUIT, reading these boards I tend to think that everything supports styles.
    Reading https://projects.developer.nokia.com...it/Dialog.java I think the show() variant at line 824 creates the text thing, and its style is DialogBody. If you are familiar with LWUIT, you may know how to change it. If it is not possible, it should be still viable to extract that method and put your "own" TextArea, which you can style for sure.

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105

    Re: Simple Yes-No-Dialog in LWUIT Asha501

    Quote Originally Posted by internetlabor View Post
    The back key is not handled by the dialog. when the user uses the back key, the user sees app-close-dialog. Instead back key should be handled like pessing the "No" button.
    Does this help?
    About the LWUIT thing, I am a bit baffled. The MIDP LCDUI Alert API works fine here. Consequently, I am not sure why LWUIT is not mapped correctly to the Alert class. Did you check the source code where it goes? For me it looks like a style issue as well. However, that is just a guess.

  4. #4
    Registered User
    Join Date
    Mar 2013
    Location
    Nasik, India
    Posts
    21

    Re: Simple Yes-No-Dialog in LWUIT Asha501

    Hello Karsten,
    Please check below comments for both issues.

    issues #1 - You can set the style of dialog box, text box and buttons. LWUIT makes it very easy by provided style methods (textBox.getSelectedStyle()/getPressedStyle()/getUnselectedStyle()).

    e.g.

    void ShowExitMsg()
    {

    CommandDialogExit = new Dialog();
    CommandDialogExit.setLayout(new BorderLayout());
    CommandDialogExit.getDialogStyle().setMargin(0, 0, 0, 0);
    CommandDialogExit.getDialogStyle().setPadding(0, 0, 0, 0);
    CommandDialogExit.getDialogStyle().setBgColor(16576654);
    CommandDialogExit.getDialogStyle().setBgTransparency(255);
    CommandDialogExit.addCommandListener(this);

    final TextArea txtNotice = new TextArea("You are about to exit app do you want to continue?");
    txtNotice.setEditable(false);
    txtNotice.setFocusable(false);
    txtNotice.getStyle().setBgTransparency(0);
    txtNotice.getStyle().setFgColor(0);
    txtNotice.setColumns(200);
    txtNotice.getStyle().setFont(Font.createSystemFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_SMALL));

    final Container cntShadow = new Container();
    cntShadow.setFocusable(false);
    cntShadow.getStyle().setMargin(0, 0, 0, 0);
    cntShadow.getStyle().setBgColor(15326573);
    cntShadow.getStyle().setBgTransparency(255);
    cntShadow.setPreferredH(Display.getInstance().getDisplayHeight() / 12);
    if (Display.getInstance().isEdt())
    {
    CommandDialogExit.addCommand(cmdExitYes);
    CommandDialogExit.addCommand(cmdExitNo);
    CommandDialogExit.addComponent(BorderLayout.NORTH, txtNotice);
    CommandDialogExit.addComponent(BorderLayout.SOUTH, cntShadow);
    }
    else
    {
    Display.getInstance().callSeriallyAndWait(new Runnable()
    {
    public void run()
    {
    CommandDialogExit.addCommand(cmdExitYes);
    CommandDialogExit.addCommand(cmdExitNo);
    CommandDialogExit.addComponent(BorderLayout.NORTH, txtNotice);
    CommandDialogExit.addComponent(BorderLayout.SOUTH, cntShadow);
    }
    });
    }
    CommandDialogExit.show(Display.getInstance().getDisplayHeight() / 2, 5, 0, 0, false);


    }

    issues #2 - Add key/game key listeners to dialog box and handle the event in actionPerformed(ActionEvent evt) method. So if user press back key then execution flow will go to Action performed method there you can handle the event.

    Thanks.
    Vishal Bharati.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    280

    Re: Simple Yes-No-Dialog in LWUIT Asha501

    Thanks for help to all

    the source code helps. Unfortunaetly I do find the source latest LWUIT 1.0.5 source code for asha. The link and the projects page show me older code. There seem to be some special treatment for asha.

    I have noticed that the DialogBody seem to be defined wrongly in the LWUIT Asha Theme resources. Color is set to "derive", but there is nothing to derive from. So I think that is why the default style of textarea is used.
    But I had problems overriding it with my own style. Something in my theme reading code must be wrong. I will check this.

    The blog post from Sannah about the dialog shows us how it is meant to be. But it only highlights the problem, as the lwuit-dialog does not behave this way.

    So the last idea is to create this all from scratch, like Vishal Bharati suggests.
    This gives me the opportunity to add Form.setBackCommand(). In a static method I have no instance to call this method.
    The exact code seem to generate of more "traditional" kind of dialog, not the new asha501 style. So I have not done it yet.

    In the moment I use this code:

    Code:
    static public boolean createAshaYesNoDialog(String title, String question, String yes, String no){
            
            Command okCommand = new Command(yes);
            Command noCommand = new Command(no);
            Command[] cmds = new Command[]{okCommand, noCommand};
            
            TextArea ta = new TextArea(question, 3, 30);
            ta.setEditable(false);
            ta.setUIID("Label");
            ta.getStyle().setFgColor(0xffffff);  // otherwise text is only light gray
            
            Command pressedCmd =  Dialog.show(
                    title, 
                    ta, 
                    okCommand,
                    cmds,
                    Dialog.TYPE_CONFIRMATION, 
                    null, /* icon */
                    0, //  timeout, 
                    null); // transition
            return (pressedCmd == okCommand);                
        }
    This code works and looks OK. It is not handling the back key yet.

    Regards

    Karrsten Meier

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105

    Re: Simple Yes-No-Dialog in LWUIT Asha501

    Quote Originally Posted by internetlabor View Post
    I do find the source latest LWUIT 1.0.5 source code for asha.
    The latest version is 1.0.6. Are you on the latest SDK and do you use the correct JAR for Asha?

  7. #7
    Registered User
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    280

    Re: Simple Yes-No-Dialog in LWUIT Asha501

    Thanks for nottfy me of the new version.
    I use Asha SDK 1.0. and the LWUIT version which was included in the plugins folder
    The SDK come with an SDK manager, which does not work for me,
    So I have never updated it.

    Ok, I will try everything also with the new sdk 1.1

  8. #8
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105

    Re: Simple Yes-No-Dialog in LWUIT Asha501

    On 6th of August, the final version of the SDK was released, according to the documentation that brought us LWUIT 1.0.6. I have not doubled-checked that yet. Furthermore, I did not get it via update either.

    The SDK 1.1 (Nokia Asha 502) can be installed side-by-side to your existing SDK 1.0 (Nokia Asha 501).
    Anyway, because there are several JARs of LWUIT, which one do you use?

  9. #9
    Registered User
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    280

    Re: Simple Yes-No-Dialog in LWUIT Asha501

    The problem also exists in the new Asha SDK 1.1 beta with LWUIT 1.1.2 (according to release notes in plugin folder) and jar file "S40-asha2013.jar", and without loading my own theme. The simple dialog looks like the screenshot attached in my first post, and the back-key is not handled.

  10. #10
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105

    Re: Simple Yes-No-Dialog in LWUIT Asha501

    Quote Originally Posted by internetlabor View Post
    I do find the source latest LWUIT source code for Asha Software Platform. The link and the projects page show me older code.
    I cannot find the source either. Because Nokia Projects are closing, I would have expected the latest version on GitHub. Nothing, yet. Well, at least we have a lot of documentation and examples in
    C:\Nokia\Devices\Nokia_Asha_SDK_1_1\plugins\lwuit\lib\asha-sdk. Did you try the Component Demo? There is a dialog (Text, 2 buttons) which works at least here as confirmation (ups, sorry that is LCDUI not LWUIT).
    Last edited by traud; 2013-10-25 at 09:06. Reason: example is LCDUI, sorry

Similar Threads

  1. LWUIT S40 Dialog issue
    By Munon in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2013-03-01, 13:17
  2. Lwuit Dialog Problem
    By rajan701v in forum Mobile Java General
    Replies: 2
    Last Post: 2012-06-07, 10:35
  3. Simple doubt LWUIT?
    By kumar1234567 in forum Mobile Java General
    Replies: 4
    Last Post: 2011-04-21, 14:18
  4. simple LWUIT issue...?
    By kumar1234567 in forum Mobile Java General
    Replies: 2
    Last Post: 2011-04-15, 14:00
  5. Dialog problem LWUIT
    By elaltaico in forum Mobile Java General
    Replies: 1
    Last Post: 2010-08-25, 12: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
  •