Curl Global Community
Dialog and moving focus - Printable Version

+- Curl Global Community (http://communities.curl.com)
+-- Forum: Discussions (http://communities.curl.com/forumdisplay.php?fid=1)
+--- Forum: General Curl questions (http://communities.curl.com/forumdisplay.php?fid=2)
+--- Thread: Dialog and moving focus (/showthread.php?tid=386)



Dialog and moving focus - alchimiste - 01-04-2012

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}
}
}
}



RE: Dialog and moving focus - heavybugtracker - 01-12-2012

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}