Pivot
  1. Pivot
  2. PIVOT-686

force focus on a Pivot (focusable) component on page load

    Details

    • Type: Improvement Improvement
    • Status: Reopened
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.5.1
    • Fix Version/s: 2.5
    • Component/s: None
    • Labels:
      None
    • Environment:
      Tested on Windows XP with Firefox 3.6.13 and 8.0.552.224

      Description

      A pivot applet will never gain focus after a page load. You always have to click on the applet, before it accepts key events. It seems not to be a JDK issue.

      I've created to examples which include textfield in the applet. One applet with pivot and one without. Only in the native applet the textfield gains the focus (works with Firefox and Chrome). The pivot never gains automaticly the focus without clicking the applet.

      Applet Version (immediate focus works):
      http://betrunken.de/media/appletFocusDemo/appletPlainDemo.html

      Pivot Version (immediate focus doesn't work):
      http://betrunken.de/media/appletFocusDemo/pivotPlainDemo.html

      Try to start typing after reload. It works only for the applet version.

      You can download the source from:
      http://betrunken.de/media/appletFocusDemo/demoApplet.jar

      The discussion thread can be found at:
      http://apache-pivot-users.399431.n3.nabble.com/request-focus-in-my-pivot-applet-on-page-load-td2085547.html

      1. pivot686_test_forceFocus_enabled.html
        2 kB
        Sandro Martini
      2. pivot686_test.html
        2 kB
        Sandro Martini
      3. kitchen-sink_test.html
        3 kB
        Sandro Martini

        Activity

        Hide
        Sandro Martini added a comment - - edited

        Just committed (in trunk) a sample test case: Pivot686.
        As a quick look, running it as a Java Application, the focus is transferred Ok in the text field, but only if I force the requestFocus() in the textInput field AFTER the window.open(display) ... maybe this could help even in the Applet execution.
        As soon as possible I'll try to run this test case even in an Applet (first inside AppletViewer, then in a real browser).

        If someone has other info, comments, etc, write here.

        Sandro

        Show
        Sandro Martini added a comment - - edited Just committed (in trunk) a sample test case: Pivot686. As a quick look, running it as a Java Application, the focus is transferred Ok in the text field, but only if I force the requestFocus() in the textInput field AFTER the window.open(display) ... maybe this could help even in the Applet execution. As soon as possible I'll try to run this test case even in an Applet (first inside AppletViewer, then in a real browser). If someone has other info, comments, etc, write here. Sandro
        Hide
        Sandro Martini added a comment -

        This requires more tests, so move to 2.0.2

        Show
        Sandro Martini added a comment - This requires more tests, so move to 2.0.2
        Hide
        Sandro Martini added a comment - - edited

        Add two sample HTML pages to try both Kitchen Sink and Pivot686 as applets.

        Note that it's required to have all pivot-2.0.2 jars in the same folder of the page.
        And even a pivot-tests-2.0.2.jar generated by the tests subproject (I'll commit asap a small change in our build.xml to enable its generation if/when needed, by a dedicated ant task).

        Using the current version of the code (from trunk) all seems to work (issue resolved), but note that in my Pivot686 test I force the focus on the TextFiled, using something like this:

        textInput.requestFocus(); // force focus on TextInput, Ok when run as a Java Application
        System.out.println("textInput has focus: " + textInput.isFocused());

        Ok, the current solution it's more an hint than a real bug fix, but I'll mark it the same as resolved (note that this could work now even because of other small changes in 2.0.2).

        Sandro

        Show
        Sandro Martini added a comment - - edited Add two sample HTML pages to try both Kitchen Sink and Pivot686 as applets. Note that it's required to have all pivot-2.0.2 jars in the same folder of the page. And even a pivot-tests-2.0.2.jar generated by the tests subproject (I'll commit asap a small change in our build.xml to enable its generation if/when needed, by a dedicated ant task). Using the current version of the code (from trunk) all seems to work (issue resolved), but note that in my Pivot686 test I force the focus on the TextFiled, using something like this: textInput.requestFocus(); // force focus on TextInput, Ok when run as a Java Application System.out.println("textInput has focus: " + textInput.isFocused()); Ok, the current solution it's more an hint than a real bug fix, but I'll mark it the same as resolved (note that this could work now even because of other small changes in 2.0.2). Sandro
        Hide
        Sandro Martini added a comment -

        add another version of the same test page, using the (new, just committed in trunk) startup_parameter forceFocus=true, so the code inside the class if true does a force of the focus in the text field.

        Show
        Sandro Martini added a comment - add another version of the same test page, using the (new, just committed in trunk) startup_parameter forceFocus=true, so the code inside the class if true does a force of the focus in the text field.
        Hide
        Sandro Martini added a comment -

        All works now using this workaround:

        textInput.requestFocus(); // force focus on TextInput, Ok when run as a Java Application, and even in Applet

        Show
        Sandro Martini added a comment - All works now using this workaround: textInput.requestFocus(); // force focus on TextInput, Ok when run as a Java Application, and even in Applet
        Hide
        Roger Whitcomb added a comment -

        Note: I have to do this on new dialogs, even as a desktop program (DesktopApplicationContext), so maybe this is just necessary, or maybe there is something deeper in Window or Component classes that needs to happen?!

        Show
        Roger Whitcomb added a comment - Note: I have to do this on new dialogs, even as a desktop program (DesktopApplicationContext), so maybe this is just necessary, or maybe there is something deeper in Window or Component classes that needs to happen?!
        Hide
        Sandro Martini added a comment -

        Hi Roger,
        yes, probably you have to look deeper inside WTK classes.
        And even after this, I think you have the same to force the focus in some text component ...

        Be free to reopen this issue (and reassign to you) if you want to make more tests/improvements on this ... and post some update.

        Show
        Sandro Martini added a comment - Hi Roger, yes, probably you have to look deeper inside WTK classes. And even after this, I think you have the same to force the focus in some text component ... Be free to reopen this issue (and reassign to you) if you want to make more tests/improvements on this ... and post some update.
        Hide
        Sandro Martini added a comment -

        For 2.1, verify if implement something like this:
        a Window/Dialog/Frame attribute like "focusComponent='$textInput'" , where "textInput" is the bxml:id of the component to gain the focus once the window or dialog comes up

        Show
        Sandro Martini added a comment - For 2.1, verify if implement something like this: a Window/Dialog/Frame attribute like "focusComponent='$textInput'" , where "textInput" is the bxml:id of the component to gain the focus once the window or dialog comes up
        Hide
        Sandro Martini added a comment - - edited

        Reopened and reassigned to 2.1 for a real solution (currently here we put a workaround).

        Show
        Sandro Martini added a comment - - edited Reopened and reassigned to 2.1 for a real solution (currently here we put a workaround).
        Hide
        Sandro Martini added a comment -

        As a workaround, after opening the container (window, etc), force a requestFocus() , for example on Window, Frame, TextInput, etc ...

        Show
        Sandro Martini added a comment - As a workaround, after opening the container (window, etc), force a requestFocus() , for example on Window, Frame, TextInput, etc ...
        Hide
        Sandro Martini added a comment - - edited

        make this optional setting callable even from bxml (if possible)

        Show
        Sandro Martini added a comment - - edited make this optional setting callable even from bxml (if possible)

          People

          • Assignee:
            Sandro Martini
            Reporter:
            Felix
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development