Questions tagged [setfocus]

For questions related to the SetFocus method, which moves the focus to the specified form or Window.

The SetFocus method moves the focus to the specified Form, the specified control on the Form/Window, or to the specified Window. You can use the SetFocus method when you want a particular field or control or Window to have the focus so that all user input is directed to this object.

417 questions
168
votes
16 answers

how to put focus on TextBox when the form load?

I have in my C# program textBox I need that when the program start, the focus will be on the textBox I try this on Form_Load: MyTextBox.Focus(); but it wont work
Gali
  • 13,473
  • 25
  • 77
  • 105
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 Zortéa De Conto
  • 1,725
  • 3
  • 14
  • 17
54
votes
7 answers

Correct way to focus an element in Selenium WebDriver using Java

What's the equivalent of selenium.focus() for WebDriver? element.sendKeys(""); or new Actions(driver).moveToElement(element).perform(); I have tried both of them and they worked, but which one would always work on all elements? Which one is the…
questions
  • 2,197
  • 4
  • 21
  • 37
49
votes
8 answers

Setting focus to iframe contents

I have a page with a document.onkeydown event handler, and I'm loading it inside an iframe in another page. I have to click inside the iframe to get the content page to start "listening". Is there some way I can use JavaScript in the outer page to…
Jimmy
  • 81,547
  • 17
  • 114
  • 135
46
votes
10 answers

Set focus on an input with Ionic 2

SOLVED : import { Component, ViewChild} from '@angular/core'; import { Keyboard } from 'ionic-native'; @Component({ templateUrl: 'build/pages/home/home.html' }) export class HomePage { @ViewChild('input') myInput ; constructor() {} …
Thomas
  • 1,189
  • 2
  • 11
  • 19
43
votes
7 answers

Set keyboard focus to a

I have the following code snippet:
webdad3
  • 8,436
  • 28
  • 114
  • 206
41
votes
10 answers

Set focus to field in dynamically loaded DIV

What is the proper method to set the focus to a specific field within a dynamically loaded DIV? $("#display").load("?control=msgs"); // loads the HTML into the DIV $('#display').fadeIn("fast"); // display it $("tex#header").focus(); // ??…
MrG
  • 5,097
  • 17
  • 46
  • 66
31
votes
10 answers

How to Set Focus on JTextField?

I make my game run without mouse so using pointer is not a choice. High Score menu will show when player lose. this is my code highScore=new MyTextField("Your Name"); highScore.addKeyListener(this); highScore.setFont(font); …
Kenjiro
  • 739
  • 1
  • 12
  • 31
31
votes
6 answers

KeyCode_Enter to next edittext

In edittext, after typing 'Enter' key, system make a new line inside it. I'd like to focus on next edittext, no new line. how to code? my code in xml is below
soclose
  • 2,683
  • 12
  • 47
  • 60
22
votes
1 answer

How to Set the Initial Focus of the control in the particular window?

I created an application in which I use window procedure to keep track of all the controls in the window. My question is, how do I initially set the focus to the first created control in the window?
karthik
  • 16,456
  • 70
  • 72
  • 119
20
votes
9 answers

Set focus to textbox in ASP.NET Login control on page load

I am trying to set the focus to the user name TextBox which is inside an ASP.NET Login control. I have tried to do this a couple of ways but none seem to be working. The page is loading but not going to the control. Here is the code I've…
anD666
  • 591
  • 3
  • 8
  • 24
18
votes
2 answers

In Javascript setting a textarea with focus() does not work if called as a child window

I have a simple test page that sets the focus to a textarea on an oninit function. However the exact code fails to do this if the page is called as a child. Putting alert box proves that the oninit function is being called but fails to put the focus…
Ian Smith
  • 191
  • 1
  • 1
  • 5
16
votes
1 answer

Android WebView - Setting HTML Field focus using Javascript

I have an application with just a visible WebView component to it which is used to display some dynamically generated HTML (can run Javascript too). It's enabled for the WebView. For a few pages I am trying to set the focus of one of the input text…
Swaroop
  • 858
  • 1
  • 11
  • 25
14
votes
4 answers

Setting focus on a button is not working

I am trying to set the focus to a button while the user presses the Enter key in the text box. But it is not working. I am using the Internet Explorer 8 browser. Am I missing something? $("input.Box").live('keydown', function(e) { if (e.keyCode…
Lamps
  • 1,620
  • 7
  • 24
  • 40
14
votes
1 answer

Tkinter set focus on Entry widget

Here is my code: import tkinter as tk userData = tk.Tk() nbdays = tk.IntVar() mainframe = tk.Frame(userData, relief= 'raised', borderwidth=1) tk.Label(mainframe, text = 'Number of days', font = 10).place(x=2, y = 30) tk.Entry(mainframe, width= 8,…
Cyrus TNZ63
  • 169
  • 1
  • 1
  • 6
1
2 3
27 28