[OPEN] [#426] X.MessageBox.Show( .. ) doesn't get focus after DirectEvent

Page 1 of 2 12 LastLast
  1. #1

    [OPEN] [#426] X.MessageBox.Show( .. ) doesn't get focus after DirectEvent

    I have a TextBox that has focus. A DirectEvent is called which contains the following code:

    X.MessageBox.Show( new MessageBoxConfig() {
                    Title = "Failure",
                    Message = "Failed.",
                    Buttons = MessageBox.Button.OK,
                    Modal=true
                } );
    TextBox1.Focus();
    The MessgeBox appears and though the modal greys the page and emphasis moves to the MessageBox, text input still goes to the original TextBox. Pressing space should be enough to close the MessageBox, but the space types into the original TextBox where focus was before instead.

    Interestingly, ENTER still closes the modal.
    Last edited by Daniil; Feb 03, 2014 at 5:28 AM. Reason: [OPEN] [#426]
  2. #2
    Actually I figured out this issue. In the same DirectEvent, Focus() (and a few other Server-side calls) are called after the Show(). So because Show is asynchronous, the focus is definitely being sent back to the original TextBox which makes sense but also doesn't. I originally thought the MessageBox should have the focus and queue or disregard since it takes over client-side view, then continue after the modal is closed, but that isn't the case.

    I suppose there is a reasonable question about how Ext.Net handles the rendered stream that follows a Show() on a Modal.

    The simple solution to my problem is to Set the Focus in the Handler of the MessageBox instead. The problem with that is I have to write client-side code in that case and cannot use Server-side calls anymore.

    However, another argument could be made that another solution here is that Ext.Net can manage to attach all server-side calls that render client-side code that fall after a modal Show to the Handler of the Modal Window instead of appended to the stream.

    I realize that could be a challenge, but it makes sense chronologically, and it's entirely possible to flip a switch inside Show() that turns all rendering over to another stream that renders the Handler of the Modal in the exact same way as appending it otherwise would to the end of the stream.

    Vladimir, consider this challenge?

    So in my example above, the following rendering would change from:
    script: "Ext.Msg.show({"title":"Failed","buttons":Ext.Msg.OK,"msg":"Failure."});App.TextBox1.focus();"
    ... to ...

    script: "Ext.Msg.show({"title":"Failed","buttons":Ext.Msg.OK,"msg":"Failure.","Handler":"App.TextBox1.focus();"});"
    Maybe it can be an advanced option?
    Last edited by michaeld; Oct 12, 2013 at 10:21 AM.
  3. #3

    Official Feature Request...

    I spent some more time thinking about this topic and our development efforts over the next month or two.

    Right now the admin side of the web application refreshes the page after every major edit. This is quite expensive, especially when we've got a robust ajax library that should be pretty adept at DirectEvent updates to the page after the post.

    In the next major rev, we'll be posting a modal box to the user to indicate their update was successful, then update the contents of the page without the refresh. We want to keep the coding of updates to the client mostly server-side calls which will work great, but there will be definitely be times we need the updates to come after the modal is closed, while other times, it'll be okay to update the page underneath. So having the option to post events to the handler of the modal becomes something we need to be an option we can exploit.
  4. #4
    Hello!

    Thank you! We will discuss your request.
  5. #5
    Great. I'd even consider it pretty novel if we could switch back and forth between render streams that can be attached to modals or other windows, listeners, etc.

    Example:

    X.CurrentRender = new Renderer();
    ctrl.Focus();
    ctl.Text = '';
    X.Msg.Alert("Test", "Test", X.CurrentRender).Show();
    X.CurrentRender = X.DefaultRender;
    X.CurrentRender = new Renderer();
    ctrl.Focus();
    ctl.Text = '';
    Btn1.Listeners.Renderer= X.CurrentRender;
    X.CurrentRender = X.DefaultRender;
    Or something like that might be pretty cool.
  6. #6
    I mentioned this last suggestion again in item 2 here: http://forums.ext.net/showthread.php?27212-Ext-Net-3-0
  7. #7
    I guess you finally started this thread summarizing the feature request:
    http://forums.ext.net/showthread.php?27782
  8. #8
    Yeah, I guess the new thread is significantly more detailed. I forgot about this diversion from the original topic in this thread.

    Honestly though, when I consider the original topic and how easy it is to make this mistake, I wish there was a simple way to quash all focus events that follow after a MessageBox().Show() command. Maybe it's still an easy addressed fix. Set a variable and prevent additional focus calls? I dunno. Plausible though.
    Last edited by michaeld; Jan 30, 2014 at 12:10 PM.
  9. #9

    Singular Event Detection on the Server-side.

    As I started thinking about this more, I'm realizing that focus makes sense as a function that should be a request that's globally singular. That is, it makes no sense to set focus for one control in the same page life-cycle. If the server-side code had a generalized way to enforce singular requests, it could exception on redundant requests and save developers spending a lot of time debugging.

    I don't know if you'd like to support this concept but I think it's a valuable enforcement you might want to consider server-side. I can't imagine there aren't other methods that might require a singular-request enforcement besides focus. For instance, MessageBox().Show() or any window modal operation would make sense as globally enforced as singular events. That is, we shouldn't code Show() twice in the same life-cycle.

    But a general model internally might be easy enough to implement. So, example, internally instead of Call("setFocus") internally, implement as: TestSingularEvent("focus"); Call("setFocus");

    TestSingularEvent would pass a name that is internally used to enforced the singular event of the type. Ultimately it would add a global HashSet list that if already appears would exception if it does and notify the developer they coded something badly.

    In the case of a modal event, you'd test TestSingularEvent("modal"). So in the case of MessageBox.Show(), this would be set, then if the developer also mistakenly called Wind1.Show() (and it's Modal=true), then TestSingularEvent("modal") would exception.

    Anyway, it's just an idea but easy-peasy to implement. Also, an enum would be faster than a string if you wanted to limit the list of singular-type-identities to enforce.
  10. #10
    It sounds interesting, thank you for the suggestion.

    Though, IMO, we should leave something for developers to code. This way Ext.NET might degenerate to a button which a developer could click and get a ready application:)

    I created an Issue and associated to Geoffrey. He is much better than me to decide it should/might be implemented.
    https://github.com/extnet/Ext.NET/issues/426
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: Jun 06, 2013, 5:41 AM
  2. Cursor not show after textField.focus()
    By Aod47 in forum 2.x Help
    Replies: 0
    Last Post: Aug 27, 2012, 8:06 AM
  3. [CLOSED] Dynamically added Ext.Net.TextField doesn't get focus on left click in Firefox
    By gdg@abaksoftware.com in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Jul 31, 2012, 7:45 AM
  4. [CLOSED] Focus X.Msg.Show
    By majunior in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 27, 2011, 4:02 PM
  5. MessageBox does't show till after method
    By jarremw in forum 1.x Help
    Replies: 3
    Last Post: Jun 23, 2009, 4:08 AM

Posting Permissions