1. #1
    Ext User
    Join Date
    May 2008
    Posts
    23
    Vote Rating
    0
    rzschech is on a distinguished road

      0  

    Default [FIXED] [1.2] MessageBox.prompt enter key does not dismiss message box

    [FIXED] [1.2] MessageBox.prompt enter key does not dismiss message box


    When entering text into a MessageBox.prompt the enter key should close the message box. I think this should be built into to the toolkit but I can't seem to get this to work even if I put in my own event listeners.

    Test Code:
    Code:
    package test;
    
    import com.extjs.gxt.ui.client.Events;
    import com.extjs.gxt.ui.client.event.BaseEvent;
    import com.extjs.gxt.ui.client.event.ComponentEvent;
    import com.extjs.gxt.ui.client.event.KeyListener;
    import com.extjs.gxt.ui.client.event.Listener;
    import com.extjs.gxt.ui.client.event.MessageBoxEvent;
    import com.extjs.gxt.ui.client.widget.MessageBox;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.KeyboardListener;
    
    public class MessageBoxTestEntryPoint implements EntryPoint {
        @Override
        public void onModuleLoad() {
            final MessageBox messageBox = MessageBox.prompt("Hello", "");
            messageBox.getTextBox().setValue("FOO");
            
            messageBox.getTextBox().addListener(Events.Activate, new Listener() {
                @Override
                public void handleEvent(BaseEvent be) {
                    messageBox.close();
                }
            });
            
            messageBox.getTextBox().addKeyListener(new KeyListener() {
                @Override
                public void componentKeyPress(ComponentEvent event) {
                    if (event.getKeyCode() == KeyboardListener.KEY_ENTER) {
                        messageBox.close();
                    }
                }
            });
            
            messageBox.addCallback(new Listener<MessageBoxEvent>() {
                public void handleEvent(MessageBoxEvent mbe) {
                    if (mbe.buttonClicked.getItemId().equals(MessageBox.CANCEL)) {
                        return;
                    }
                    if (mbe.value == null) {
                        return;
                    }
                    System.out.println(mbe.value);
                }
            });
        }
    }

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    If you are suggesting a feature here, why are you posting it inthe bug forum?

  3. #3
    Ext User
    Join Date
    May 2008
    Posts
    23
    Vote Rating
    0
    rzschech is on a distinguished road

      0  

    Default


    Hmm good point. Sorry about that. Shall I repost it there?

  4. #4
    Sencha Premium Member
    Join Date
    Oct 2008
    Posts
    79
    Vote Rating
    0
    Cputerace is on a distinguished road

      0  

    Default


    Ok so a feature request would be to have it included by default, but the bug still stands that mb.getTextBox().addKeyListener() does not work to capture the enter key event. Can someone comment on that bug?

  5. #5
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    I just fixed that one. Will be in SVN soon.

  6. #6
    Sencha Premium Member
    Join Date
    Oct 2008
    Posts
    79
    Vote Rating
    0
    Cputerace is on a distinguished road

      0  

    Default


    So to verify, the fix will allow specifically this code:
    messageBox.getTextBox().addKeyListener(new KeyListener() {
    @Override
    public void componentKeyPress(ComponentEvent event) {
    if (event.getKeyCode() == KeyboardListener.KEY_ENTER) {
    messageBox.close();
    }
    }
    });

    to run?

  7. #7
    Sencha Premium Member
    Join Date
    Oct 2008
    Posts
    79
    Vote Rating
    0
    Cputerace is on a distinguished road

      0  

    Default


    p.s. thanks!

  8. #8
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Yes. The problem is that the textbox doenst get attached. So for now you can call
    Code:
    ComponentHelper.doAttach(box.getTextBox())
    But dont forget to detach it after the dialog closes again:

    Code:
    ComponentHelper.doDetach(box.getTextBox())

  9. #9
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Fixed in SVN.

Thread Participants: 2