# Focus on a TextInput in code

**URL:** <https://forums.fusetools.com/t/focus-on-a-textinput-in-code/4861>\
**Category:** How-to Discussions\
**Created:** [June 24, 2015, 4:32pm UTC](https://forums.fusetools.com/t/focus-on-a-textinput-in-code/4861 "2015-06-24T16:32:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_Inge\_Asbjornsen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/sean_inge_asbjornsen/32/578_2.png) [@Sean\_Inge\_Asbjornsen](https://forums.fusetools.com/u/Sean_Inge_Asbjornsen)\
**Post date:** [June 24, 2015, 4:32pm UTC](https://forums.fusetools.com/t/focus-on-a-textinput-in-code/4861/1 "2015-06-24T16:32:45Z")

</div>

Trying to get a TextInput to gain focus when clicking a button. I have tried setting:

\< ZTextInput Focus.IsFocusable=“true” PlaceholderText=“Comment” ux:Name=“TextInput1” DockPanel.Dock=“Top”/\>

And calling focus from code like this:

Fuse.Input.Focus.GiveTo(TextInput1);

But it is not working. How do you set focus to a TextInput?

---

<div class="post-metadata">

**Author:** ![Bjeld](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@Bjeld](https://forums.fusetools.com/u/Bjeld)\
**Post date:** [October 9, 2015, 9:31am UTC](https://forums.fusetools.com/t/focus-on-a-textinput-in-code/4861/2 "2015-10-09T09:31:43Z")

</div>

This seems to work in the Fuse Simulator:

```auto
<Panel Margin="20,20,20,20">
    <TextInput Alignment="VerticalCenter" ux:Name="txt1" />
    <Button Height="60" Text="Create Memory" Alignment="Bottom" ux:Name="btn1">
        <Clicked>
            <GiveFocus Target="txt1" />
        </Clicked>
    </Button>
</Panel>

```

---

<div class="post-metadata">

**Author:** ![Jake\_Taylor](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jake_taylor/32/512_2.png) [@Jake\_Taylor](https://forums.fusetools.com/u/Jake_Taylor)\
**Post date:** [October 12, 2015, 9:10pm UTC](https://forums.fusetools.com/t/focus-on-a-textinput-in-code/4861/3 "2015-10-12T21:10:00Z")

</div>

Yes, ideally this is the kind of thing you’ll want to be doing in UX markup. Did Bjeld’s solution work for you, Sean?

---

<div class="post-metadata">

**Author:** ![patrice](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@patrice](https://forums.fusetools.com/u/patrice)\
**Post date:** [October 21, 2016, 5:23pm UTC](https://forums.fusetools.com/t/focus-on-a-textinput-in-code/4861/4 "2016-10-21T17:23:06Z")

</div>

With the lastest Fuse version, as of today, I cannot focus on a TextInput. Meaning, in the simulator, I have to press TAB so I can start typing in the input. On the phone preview app, I cannot type in the input field at all no matter what.

Any idea what can cause this?

---

<div class="post-metadata">

**Author:** ![kusma](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kusma/32/595_2.png) [@kusma](https://forums.fusetools.com/u/kusma)\
**Post date:** [October 25, 2016, 10:56am UTC](https://forums.fusetools.com/t/focus-on-a-textinput-in-code/4861/5 "2016-10-25T10:56:35Z")

</div>

@patrice: This seems to be unrealted to the issue discussed here. Could you perhaps open a new thread, so other users with similar issues will have an easier time finding the discussion?
