# Set TextInput Focus.Delegate

**URL:** <https://forums.fusetools.com/t/set-textinput-focus-delegate/5673>\
**Category:** How-to Discussions\
**Created:** [February 14, 2018, 1:12pm UTC](https://forums.fusetools.com/t/set-textinput-focus-delegate/5673 "2018-02-14T13:12:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhvl\_Golakiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/dhvl_golakiya/32/227_2.png) [@Dhvl\_Golakiya](https://forums.fusetools.com/u/Dhvl_Golakiya)\
**Post date:** [February 14, 2018, 1:12pm UTC](https://forums.fusetools.com/t/set-textinput-focus-delegate/5673/1 "2018-02-14T13:12:52Z")

</div>

Hi,

I know how to set Focus.Delegate of TextInput on same UX file component. But how can I set Focus.Delegate on other UX file component like I want to set on `messageView` of `MessageChat`. How can I access other ux file component?

MainView.ux:

```auto
<App>
    <Android.StatusBarConfig Color="Black" IsVisible="true" />
    <DockPanel Margin="12,25,12,0" >
        <BottomBarBackground Dock="Bottom" />
        <TextInput ux:Name="TextBox" Margin="8" PlaceholderText="Enter Text Here" PlaceholderColor="#8f8f8fdd" FontSize="24" TextColor="Black" Dock="Bottom" Height="50" />
       <MessageChat/>
    </DockPanel>
</App>

```

MessageChat.ux:

```auto
<Panel ux:Class="MessageChat">
    <JavaScript>
        var Observable = require('FuseJS/Observable');
        var messages = [ { items: "Hii" },
                        { items: "Hello" },
                        { items: "Good Mornign!" },
                        { items: "How are you ?" },
                        { items: "What do you do ?" } ];

        module.exports = {
            messages: messages
        }
    </JavaScript>
    <ScrollView LayoutMode="PreserveScrollPosition" ux:Name="scrollView" AllowedScrollDirections="Vertical" Dock="Bottom" Height="90%" Width="100%" >
            <StackPanel ux:Name="messageView" Alignment="Bottom" ItemSpacing="8">
                <Each Items="{messages}" >
                    <Rectangle ux:Name="sendMessage" CornerRadius="25" Dock="Right" Color="#329af0" Padding="10" X="0" Y="0" >
                        <Text Value="{items}" TextWrapping="Wrap" Alignment="CenterRight" TextColor="White" FontSize="18" />
                    </Rectangle>
                </Each>
            </StackPanel>
        </ScrollView>
</Panel>

```

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [February 14, 2018, 1:33pm UTC](https://forums.fusetools.com/t/set-textinput-focus-delegate/5673/2 "2018-02-14T13:33:37Z")

</div>

I don’t think you can. If it was the other way around, you could do away with [ux:Dependency](https://www.fusetools.com/docs/ux-markup/dependencies), but this is not the case.

To do the focus delegation, you need to refer to elements by their `ux:Name`, and those are only available in the same scope. Why not just put the `TextInput` inside of the `MessageChat` component?

Could you explain the use case better? Perhaps there could be a workaround with `ux:Dependency` and `GiveFocus` still.

---

<div class="post-metadata">

**Author:** ![Dhvl\_Golakiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/dhvl_golakiya/32/227_2.png) [@Dhvl\_Golakiya](https://forums.fusetools.com/u/Dhvl_Golakiya)\
**Post date:** [February 14, 2018, 1:44pm UTC](https://forums.fusetools.com/t/set-textinput-focus-delegate/5673/3 "2018-02-14T13:44:30Z")

</div>

The `MessageChat` is a one components in `MainPage`. Many separate components are in that page so reducing code in one file, I am putting it outside of `MainPage`. Also `MessageChat` is using in other Page so for code reusability, I put it in other file.

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [February 14, 2018, 1:47pm UTC](https://forums.fusetools.com/t/set-textinput-focus-delegate/5673/4 "2018-02-14T13:47:52Z")

</div>

This calls for trouble, at least in my book.

If you have two instances of `MessageChat`, which of those would hold the element that you want to use as the focus delegate of that `TextInput`? That won’t work; you need to rethink how you split up the UX code - I suggest putting the `TextInput` right where it belongs, inside of that component.

---

<div class="post-metadata">

**Author:** ![Dhvl\_Golakiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/dhvl_golakiya/32/227_2.png) [@Dhvl\_Golakiya](https://forums.fusetools.com/u/Dhvl_Golakiya)\
**Post date:** [February 14, 2018, 1:55pm UTC](https://forums.fusetools.com/t/set-textinput-focus-delegate/5673/5 "2018-02-14T13:55:54Z")

</div>

Ahh…that is also a problem. Thanks. But `MainPage` has lots of code so I want to put `MessageChat` code outside of it.

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [February 14, 2018, 1:59pm UTC](https://forums.fusetools.com/t/set-textinput-focus-delegate/5673/6 "2018-02-14T13:59:04Z")

</div>

> **Dhvl Golakiya wrote:**
> 
> I want to put `MessageChat` code outside of it.

Do it. Just move the `TextInput` where it belongs.

---

<div class="post-metadata">

**Author:** ![Dhvl\_Golakiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/dhvl_golakiya/32/227_2.png) [@Dhvl\_Golakiya](https://forums.fusetools.com/u/Dhvl_Golakiya)\
**Post date:** [February 14, 2018, 2:00pm UTC](https://forums.fusetools.com/t/set-textinput-focus-delegate/5673/7 "2018-02-14T14:00:53Z")

</div>

Thanks Uldis. Will do that

---

<div class="post-metadata">

**Author:** ![Dhvl\_Golakiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/dhvl_golakiya/32/227_2.png) [@Dhvl\_Golakiya](https://forums.fusetools.com/u/Dhvl_Golakiya)\
**Post date:** [February 23, 2018, 3:39am UTC](https://forums.fusetools.com/t/set-textinput-focus-delegate/5673/8 "2018-02-23T03:39:51Z")

</div>

Can we set TextInput Focus.Delegate property in other scope? If we pass TextInput to MessageChat panel with ux:Dependency like:

```auto
<Panel ux:Class="MessageChat">
    <TextInput ux:Dependency="messageTextInput"/>
    ...
    ...
    ...
</Panel>

```

And in App:

```auto
<TextInput ux:Name="TextBox"/>
<MessageChat messageTextInput="TextBox"/>

```

Is it possible to set Focus.Delegate in MessageChat with this?
