focus

Winforms c# - Set focus to first child control of tab page.

Say I have a Textbox nested within a TabControl. When the form loads I would like to focus on that textbox (by default the focus is set to the tabControl). Simply calling textbox1.focus() in the Load event of the form does not appear to work. I have been able to focus it by doing the following: private void frmMainLoad(object se...

How to create a non-interactive window in MFC

In my application I have a window which I popup with small messages on it (think similar to tooltip). This window uses the layered attributes to draw alpha backgrounds etc. If I have several of these windows open at once, and I click one with my mouse, when they disappear they cause my application to lose focus (it switches focus to the...

How to keep concentrated and focused while waiting for your compiler?

When I'm working on software, I find that as soon as I have to wait more than around 6 seconds for the compiler or for the program to start (or simply for Visual Studio to process some really complicated command like, say, Space Bar), I tend to fire up the email client, or go read stuff on the Internet, or post questions on StackOverflow...

How do you set focus to the HTML5 canvas element?

I'm using the HTML5 <canvas> element in Firefox 2.0.0.16 and in Safari 3.1.2, both on my iMac. (I've tried this in Firefox 3.0 on Windows as well, also to no avail.) The tag looks like this: <td> <canvas id="display" width="500px" height="500px"> </canvas> </td> I have a button to "activate" some function...

In Applescript, how can I find out if a menu item is selected/focused?

I have a script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help menu. Here is the scri...

Possible to set tab focus in IE7 from JavaScript

Is it possible to launch a new window in JavaScript using the window.Open function, then set the focus to that tab? Here's what I'm doing today: var winRef = window.open(outUrl,wName,'left='+ wX +',top=' + wY + ',height=' + wH + ',width=' + wW + args); try { // Not all window types support the focus() property. ...

How to skip fields using javascript?

I have a form like this: <form name="mine"> <input type=text name=one> <input type=text name=two> <input type=text name=three> </form> When user types a value in 'one', I sometimes want to skip the field 'two', depending on what he typed. For example, if user types '123' and uses Tab to move to next field, I want to skip it and go to f...

How do you get yourself to focus?

What are some techniques you use to get yourself to focus on the task at hand, even if it's one that you don't really want to do? Answers along the lines of "If you have to work at focusing, get a different job" aren't useful. ...

Adding an input field to the dom and focusing it in IE

I am trying to make a div, that when you click it turns into an input box, and focuses it. I am using prototype to achieve this. This works in both Chrome and Firefox, but not in IE. IE refuses to focus the newly added input field, even if I set a 1 second timeout. Basically the code works like this: var viewElement = new Element("div"...

The Attention Deficit Programmer - Tips for staying on task?

With broadband internet being what it is, and tabbed browsing, and the crazy amounts of very entertaining social information sites, and someone down the hall asking for help with the printer (combined with your desire to be useful), and the coder next to you showing everyone clips from comedy central, and the nasty habit of wanting to de...

How to auto-focus RTE editor inside firefox?

We have a RTE editor based on htmlarea which consists of content with editmode enabled inside an iframe. The question is how to automatically bring the focus into the editor. ...

Flash: Coming back from another tab in browser, can flash listen to return to tab event of some sort ?

I got this flash application where you can click a link while watching a video. It will open a new tab and pause the video. Now when you come back to the flash application it would be nice if the video would start playing again. Is there a way, an event or so to do this ? ...

How Do I Give a Textbox Focus in Silverlight?

In my Silverlight application, I can't seem to bring focus to a TextBox control. On the recommendation of various posts, I've set the IsTabStop property to True and I'm using TextBox.Focus(). Though the UserControl_Loaded event is firing, the TextBox control isn't getting focus. I've included my very simple code below. What am I missi...

How to set/change/remove focus style on a Button in C#?

I have a couple of buttons of which I modified how they look. I have set them as flat buttons with a background and a custom border so they look all pretty and nothing like normal buttons anymore (actually, they look like Office 2003 buttons now ;-). The buttons have a border of one pixel. However when the button gets selected (gets the...

Programmatically focusing a hippo.CanvasEntry?

Consider this Python program which uses PyGtk and Hippo Canvas to display a clickable text label. Clicking the text label replaces it with a Hippo CanvasEntry widget which contains the text of the label. import pygtk pygtk.require('2.0') import gtk, hippo def textClicked(text, event, row): input = hippo.CanvasEntry() input.set...

AutoPostback with TextBox loses focus (question made clearer)

A textbox is set to AutoPostback as changing the value should cause a number of (display-only) fields to be recalculated and displayed. That works fine. However, when the field is tabbed out of, the focus briefly moves on to the next field, then disappears when the page is redrawn so there is no focus anywhere. I want the focus to be o...

How to set focus in WPF page reload?

I've got a WPF browser-like application with a few pages. When I switch between pages, I'd like to set the keyboard focus. When a page is loaded the first time, this works by calling Control.Focus() in the constructor. But when I switch between pages this does not work anymore - the focus is just on the first field, and ignores my atte...

Hosted .NET runtime and window focus, problem and inconsistencies

We have a Win32 application that hosts the .NET runtime and opens up .NET managed forms from the Win32 portion of the application. These windows are always opened as modal windows. On some machines, when these windows are closed, the Win32 window that lies behind does not get focus, but gets sent behind Word, Outlook, or whatever else ...

JavaScript: How to simulate a click to make the current input lose its focus

I have an input which at some points happens to have the focus. If the user click in the "background" of the page, the input loses its focus. I was trying to simulate the click on the background with the following code, but this doesn't work (you will notice that the input still has the focus). Any suggestion on how to write code that si...

focus lost after making another app's window topmost

I'm making another app's window topmost to ensure that a click in my app brings the other's dialog into views. The problem I'm having is that I don't get focus back to my app after the call. If the other app has more windows one of them ends up with focus, and otherwise no window (looking at the taskbar only) gets focus. Where should I s...