Question about setting Focus on a TextView in a Dialog View

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about setting Focus on a TextView in a Dialog View

Jerome Chan
How and where do I put code in to set the focus on a particular view?

I've got a DialogView with one textview in it. When the view is
instantiated by the DialogPresenter, I want the focus to be in this
textview. I''ve tried putting

   TextPresenterVarName setFocus.

in model: or onOpenView but the focus is not set. Does anyone have any
hints on where to look?


Reply | Threaded
Open this post in threaded view
|

Re: Question about setting Focus on a TextView in a Dialog View

Ian Bartholomew
Jerome,

> How and where do I put code in to set the focus on a particular view?

The easiest way is not to use any code at all!! When you create your dialog
in the ViewComposer just make sure that the view that you want to have the
initial focus on is the first sub view with it's #isTabStop aspect set to
true. The easiest place to see this is in the ViewComposers "ViewHierarchy"
view. You can change the order by using the "View Arrange" menu available on
the context menu or the main toolbars "Modify" menu.

This might conflict with the LayoutManager (if you are using a FramingLayout
for example) so you could probably get away with deferring the focus change
until Windows had fully opened the view

onViewOpened
    super onViewOpened.
    SessionManager inputState queueDeferredAction: [
        textPresenterVarName setFocus]

Ian