Questions tagged [focus]

Focus indicates the component of the graphical user interface which is currently selected to receive input.

Focus indicates the component of the graphical user interface which is currently selected to receive input. Text entered at the keyboard or pasted from a clipboard is sent to the component which currently has the focus. Typically, the focus is withdrawn from an element by giving another element the focus.

The concept is similar to a cursor in a text-based environment. However, when considering a graphical interface, there is also a mouse cursor involved. Moving the mouse will typically move the mouse cursor without changing the focus. The focus can usually be changed by clicking on a component that can receive focus with the mouse. Many desktops also allow the focus to be changed with the keyboard. By convention, the tab key is used to move the focus to the next focusable component and shift + tab to the previous one. When graphical interfaces were first introduced, many computers did not have mice, so this alternative was necessary. This feature makes it easier for people that have a hard time using a mouse to use the user interface. In certain circumstances, the arrow keys can also be used to move focus.

7243 questions
108
votes
10 answers

Using :focus to style outer div?

When I begin writing text in the textarea, I want the outer div, with a class box, to have its border turned solid instead of dashed, but somehow the :focus doesn't apply in this case. If it works with :active, how come it doesn't work with…
Weblurk
  • 6,562
  • 18
  • 64
  • 120
105
votes
15 answers

Setting EditText imeOptions to actionNext has no effect

I have a fairly complex (not really) xml layout file. One of the views is a LinearLayout (v1) with two children: an EditText(v2) and another LinearLayout(v3). The child LinearLayout in turn has an EditText(v4) and an ImageView(v5). For EditText v2 I…
Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199
104
votes
20 answers

Set mouse focus and move cursor to end of input using jQuery

This question has been asked in a few different formats but I can't get any of the answers to work in my scenario. I am using jQuery to implement command history when user hits up/down arrows. When up arrow is hit, I replace the input value with…
jerodsanto
  • 9,726
  • 8
  • 29
  • 23
102
votes
4 answers

How to listen focus change in flutter?

In Android, we can call setOnFocusChangeListener(), do something in onFocusChanged() method, but flutter does not provider onFocus() interface like onTap() in GestureDetector or onKey() in RawKeyboardListener. I have read flutter api about focus,…
coder.john
  • 1,235
  • 2
  • 12
  • 11
102
votes
4 answers

Difference between focusable and focusableInTouchMode?

I want to know the actual difference between them... When should each be used, how should each be used, and in which situations is each helpful? Give some examples and explain them in detail.
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
102
votes
9 answers

Set focus on div contenteditable element

I have a
where I define by a WYSIWYG some elements. For example

,

, etc. I would like to directly put the focus on one of these elements. For example on

. But it seems that focus() function doesn't…

sanceray3
  • 1,021
  • 2
  • 7
  • 3
100
votes
20 answers

Automatic popping up keyboard on start Activity

I got a relative simple question. I have an activity with a lot of EditText's in them. When I open the activity it automatically focusses to the first EditText and displays the virtual keyboard. How can I prevent this?
Galip
  • 5,435
  • 10
  • 37
  • 47
99
votes
18 answers

How do I set the focus to the first input element in an HTML form independent from the id?

Is there a simple way to set the focus (input cursor) of a web page on the first input element (textbox, dropdownlist, ...) on loading the page without having to know the id of the element? I would like to implement it as a common script for all my…
splattne
  • 102,760
  • 52
  • 202
  • 249
98
votes
10 answers

Set the focus on a textbox in xaml wpf

Despite some posts on this forum and others i cannot find something that tells me how to set the focus on a TextBox. I have a userControl with many labels and textBoxes. When the form is loaded I want the a particular textBox to have the focus. I…
user9969
  • 15,632
  • 39
  • 107
  • 175
96
votes
17 answers

How to set focus on a view when a layout is created and displayed?

Currently, I have a layout which contains a Button, a TextView and an EditText. When the layout is displayed, the focus will be automatically put on the EditText, which will trigger the keyboard to show up on Android phone. It is not what I want. Is…
user256239
  • 17,717
  • 26
  • 77
  • 89
91
votes
1 answer

WPF: Remove dotted border around focused item in styled listbox

I have a horizontal listbox with a custom controlIemplate. The selected item gets a dotted frame when focused. Anyone know how to get rid of it?
Vegar
  • 12,828
  • 16
  • 85
  • 151
90
votes
9 answers

Mobile Safari: Javascript focus() method on inputfield only works with click?

I have a simple input field like this. ​ And I'm trying to focus() it inside a function. So inside of a random function (doesn't matter what function it is) I have this line…
matt
  • 42,713
  • 103
  • 264
  • 397
89
votes
8 answers

Set initial focus in an Android application

In my Android application it automatically focuses the first Button I have in my layout, giving it an orange outline. How can I set the initial focus preferably in XML, and can this be set to nothing?
stealthcopter
  • 13,964
  • 13
  • 65
  • 83
85
votes
2 answers

Is it possible to change document.activeElement in JavaScript?

Is it possible to programmatically change the value of the document.activeElement property in JavaScript?
mgamer
  • 13,580
  • 25
  • 87
  • 145
85
votes
9 answers

Selecting text on focus using jQuery not working in Safari and Chrome

I have the following jQuery code (similar to this question) that works in Firefox and IE, but fails (no errors, just doesn't work) in Chrome and Safari. Any ideas for a workaround? $("#souper_fancy").focus(function() { $(this).select() });
user140550
  • 919
  • 2
  • 11
  • 21