TextInput is what you typically use or subclass when making input fields that only require a single line, like usernames, passwords, numbers, email, search fields, etc.
It has no appearance by default, which means it will be invisible until you give it a look or a text value.
If you want a text input control with a default appearance, see TextBox.
If you want to accept multiple lines of text, use TextView.
Examples
This example shows a basic TextInput with some style and a button to clear its contents.
This example shows how you can configure the layout and behavior of the on-screen keyboard when the TextInput is in focus using the InputHint, AutoCorrectHint, AutoCapitalizationHint and ActionStyle properties.
A common use-case is to have the TextInput raise an event when the user presses the return/search key on their virtual/physical keyboard.
The following example demonstrates using ActionTriggered to get an event when this happens:
<StackPanel>
<JavaScript>
var Observable = require("FuseJS/Observable");
var searchStr = Observable("Please enter a query...");
var entryStr = Observable("");
function onSearch(args) {
searchStr.value = "You entered: " + entryStr.value;
}
module.exports = {
searchStr: searchStr,
onSearch: onSearch,
entryStr: entryStr
};
</JavaScript>
<Text FontSize="20">Search</Text>
<TextInput Value="{entryStr}" PlaceholderText="Enter your query...." ActionTriggered="{onSearch}" />
<Text FontSize="20" Value="{searchStr}" />
</StackPanel>
In some cases, it might be undesirable for the virtual keyboard to disappear when a certain other ux element is pressed.
This can be done by passing a parent container to the Focus.Delegate property, causing the focus state to be delegated to the delegate target:
Specifies what the returnkey should mean. For exmaple:
ActionStyle="Send" will change the return key to a send icon if the platform supports it.
ActionStyle="Next" will make the return key focus the next TextInputControl if any. Typically
used in forms.
InputHint can change what kind of onscreen-keyboard will show on mobile export targets.
For example InputHint="Phone" will give a numerical keyboard and InputHint="Email"
will give keyboard with @ and no autocorrect
The children of the visual.
All nodes placed inside the visual in UX markup are assigned to this list.
The order of Visuals this list determines the order of layout. The Z-order
of the children is by default equal to this order, but can be manipulated
separately using methods like BringToFront and SendToBack.
Indicates the visual for this node has changed. This allows the root-level node to know
that it must draw, and any caching that it must invalidate the cache for this node.
Whether this node is currently interactable.
Disabled visuals do not receive input focus. However, they can still
be visible and block hit test for underlaying objects.
Returns whether this visual is currently visible.
Will return false if any of the ancestor visuals are hidden or collapsed.
This property can not be used to check whether a visual is hidden because it is occluded by
another visual, or is outside the view but otherwise visible.
The context parent is the semantic parent of this node. It is where non-UI structure should
be resolved, like looking for the DataContext, a Navigation, or other semantic item.
Finds the first node with a given name that satisfies the given acceptor.
The serach algorithm works as follows: Nodes in the subtree are matched first, then
it matches the nodes in the subtrees ofthe ancestor nodes by turn all the way to the
root. If no matching node is found, the function returns null.
Whether rooting of this node has started.
Note that even if this property returns true, rooting may not yet be
completed for the node. See also IsRootingCompleted.
If you override OnRooted you must call base.OnRooted() first in your derived class. No other processing should happen first, otherwise you might end up in an undefined state.
The index of the column the element occupies while in a Grid.
If not set, the grid will place the element in a cell according to its position in the child list.
The index of the row the element occupies while in a Grid.
If not set, the grid will place the element in a cell according to its position in the child list.
Called when a Visual receives a key press event while having input focus.
On mobile devices, keyboard input only applies to physical buttons (such as BackButton), not soft keyboards.
Called when a Visual receives a key release event while having input focus.
On mobile devices, keyboard input only applies to physical buttons (such as BackButton), not soft keyboards.