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
228
votes
24 answers

Focus-follows-mouse (plus auto-raise) on Mac OS X

(I don't want to hear about how crazy I am to want that! :) Focus-follows-mouse is also known as point-to-focus, pointer focus, and (in some implementations) sloppy focus. [Add other terms that will make this more searchable!] X-mouse
dreeves
  • 26,430
  • 45
  • 154
  • 229
224
votes
18 answers

Set Focus on EditText

I have an EditText-Field and set an OnFocusChangeListener for it. When it has lost focus, a method is called, which checks the value of the EditText with one in the database. If the return-value of the method is true, a toast is shown and the focus…
Andreas Schneider
  • 2,855
  • 3
  • 18
  • 18
213
votes
12 answers

WPF and initial focus

It seems that when a WPF application starts, nothing has focus. This is really weird. Every other framework I've used does just what you'd expect: puts initial focus on the first control in the tab order. But I've confirmed that it's WPF, not just…
Joe White
  • 94,807
  • 60
  • 220
  • 330
182
votes
16 answers

How do I put focus on a TextBox when a form loads?

I have a TextBox in my C# program. I need focus to be on this TextBox when the program starts. I tried this on Form_Load: MyTextBox.Focus(); but it doesn't work. How do I put focus on this when the form loads?
Gali
  • 14,511
  • 28
  • 80
  • 105
165
votes
5 answers

CSS: Change parent on focus of child

Let's say you have something like:
I want to change the appearance of the parent/siblings when the child receives focus. Are there any CSS…
AaronF
  • 2,841
  • 3
  • 22
  • 32
158
votes
11 answers

How to shift focus to the next TextField in Flutter?

I am new to Flutter. I am building a form with multiple text inputs using following widgets: Form, TextFormField. The keyboard that appears doesn't show "next" (which should shift the focus to next field) field action instead it is "done" action…
Harsh Bhikadia
  • 10,095
  • 9
  • 49
  • 70
152
votes
5 answers

How to remove focus from input field in jQuery?

I am setting the focus on a certain input field when loading a page using the following line: $('#myInputID').focus(); Is there a way that I can undo or remove this focus when hovering over a certain element? (The focus does not have to be reset…
user2571510
  • 11,167
  • 39
  • 92
  • 138
138
votes
16 answers

EditText, clear focus on touch outside

My layout contains ListView, SurfaceView and EditText. When I click on the EditText, it receives focus and the on-screen keyboard pops up. When I click somewhere outside of the EditText, it still has the focus (it shouldn't). I guess I could set up…
note173
  • 1,825
  • 2
  • 14
  • 15
133
votes
9 answers

Set focus on textbox in WPF

How to set the focus on an TextBox element in WPF I have this code: txtCompanyID.Focusable = true; txtCompanyID.Focus(); ...but it is not working. Any idea?
priyanka.sarkar
  • 25,766
  • 43
  • 127
  • 173
133
votes
20 answers

How to remove the focus from a TextBox in WinForms?

I need to remove the focus from several TextBoxes. I tried using: textBox1.Focused = false; Its ReadOnly property value is true. I then tried setting the focus on the form, so as to remove it from all the TextBoxes, but this also fails to…
Callum Rogers
  • 15,630
  • 17
  • 67
  • 90
130
votes
11 answers

Enable :focus only on keyboard use (or tab press)

I want to disable :focus when it's not needed because I don't like how my navigation looks when the focus is on it. It uses the same style as .active and it's confusing. However I don't want to get rid of it for people who use keyboard. I was…
Miro
  • 8,402
  • 3
  • 34
  • 72
121
votes
4 answers

Setting focus on an HTML input box on page load

I'm trying to set the default focus on an input box when the page loads (example: google). My page is very simple, yet I can't figure out how to do this. This is what I've got so far: Password Protected Page
Chris
  • 2,905
  • 5
  • 29
  • 30
114
votes
11 answers

WPF: How to programmatically remove focus from a TextBox

I want to add a simple (at least I thought it was) behaviour to my WPF TextBox. When the user presses Escape I want the TextBox he is editing to have the text it had when the user started editing, AND I want to remove the focus from the TextBox. I…
jpsstavares
  • 3,303
  • 5
  • 25
  • 32
113
votes
6 answers

Set element focus in angular way

After looking for examples of how set focus elements with angular, I saw that most of them use some variable to watch for then set focus, and most of them use one different variable for each field they want to set focus. In a form, with a lot of…
Tiago
  • 1,735
  • 3
  • 14
  • 19
109
votes
16 answers

Disable orange outline highlight on focus

I am coding an app using jQuery, jqTouch and phonegap and have run across a persistent problem which arises when a user submits a form using the Go button on the soft keyboard. Although it is easy to get the cursor to move to the appropriate form…
eggdeng
  • 1,099
  • 2
  • 8
  • 3