Curl Global Community

Full Version: Dialog and moving focus
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, everybody, Happy new year.

I want to move focus to the TextField in the parent while Dialog is displaying with non modal mode.

But before the Dialog object closes, it's impossible to move focus to the TextField.

How can I move focus to it?

Code:
{curl 7.0 applet}
{curl-file-attributes character-encoding = "utf8"}
{def f = {TextField}}
{def dlg = {Dialog
    {CommandButton
     label="Move to focus",
     {on Action do
      {f.request-key-focus}
     }
    }
   }
}
{spaced-vbox
f,
{CommandButton
label="Show dialog",
{on Action do
  {dlg.show title="Focus Test", modal?=false}
}
}
}
Could you put your screen layout into a View ? If you could, then calling View.show before {f.request-key-focus} will do what you want .

But if you have to put your screen layout within a AppletView(such as within the browser), I don't know how to do this .
Code:
{def f = {TextField}}
{def v =
    {View
        {spaced-vbox
            f,
            {CommandButton
                label="Show dialog",
                {on Action do
                    {dlg.show center?=false, title="Focus Test", modal?=false }
                }
            }
        },
    {on WindowClose do
      {exit 0}
    }
    }
}
{def dlg = {Dialog
               {CommandButton
                   label="Move to focus",
                   {on Action do
                       {after 0s do
                           {v.show}
                           {f.request-key-focus}
                       }
                   }
               }
           }
}

{v.show}