focus

Set system focus on my application

I have an application that will mainly operate in the background. I want certain system events that it handles to cause the app to steal focus from the foreground app, whatever that is. But UIElement.Focus() seems to only set the focus within the WPF app. That is, if the WPF app already has the focus as a whole, then Focus() sets the ...

AS3 - Output what object has keyboard focus?

I'm having a problem with AS3 and keyboard focus, and I'm wondering if there is a variable or a function I can use that will output to screen the name of the object that currently has keyboard focus? ...

Deselect contents of a textbox with javascript

I understand that with javascript you can select the contents of a textbox with the following code (in jQuery): $("#txt1").select(); Is there a way to do the opposite? To deselect the content of a textbox? I have the focus event of a series of textboxes set to select the contents within them. There are times now that I want to focu...

WPF focus textbox after Window is restored/activated from minimized state

Hello, I have a simple WPF application where user is able to minimize my application window. After user restores Window from minimized state I need to set focus to certain TextBox. If user before minimizing Window has not changed focus, then after restoring application everything is fine. But problem comes when user has changed focu...

Unable to set focus on a ListboxItem

Hi, I have a listbox whose ItemSource property is bound to a ViewModel. This ViewModel has an ICollectionView property which is a collection of custom objects. I am loading this collection view as a tree structure in the Listbox. My requirement is to use the arrow keys to navigate along the tree view. I wrote the code to collapse an ite...

Multiple app windows activation not working correctly

I have a Delphi application that has a document browser as the main form. When the user opens a document, we open an editor window. We want to have each editor with a button on the task bar, as well as the main form. I've applied the normal code to do this (below), but when I click on the main form after using the editor window the edito...

DataGridView: FullRowSelect and Focus

I've got a DataGridView in a modal window with a list of options for my program. The grid has two collumns. The first one contains a checkbox for selecting that option, the seccond is the name/description of that option. The winform also contains OK and cancel buttons but that's beside the point. The code below does what I want it to. Be...

Determine Where Activation Is Going When A Form Is Deactivated

Does anyone know of a way to determine which window is going to receive focus when a form is deactivated? ...

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 my app -- if I create a new Window, and just put a TextBox in it, and run the app, the Tex...

Key down event affected by buttons

Hi everybody, I'm new around here and i have a little problems with a C# application. I want to capture the key down event. This wasn't a problem at first but after i added some buttons to the form, the key down event of the form ignores the arrow keys and moves the focus from one button to the next.(The key up event works) Is there a w...

Remove focus rectangle on a UserControl

I have a WPF UserControl with Focusable="True". It's the only focusable control in the window. Whenever the user presses Tab or Alt (and especially when they Alt+Tab to another application), my UserControl acquires a dotted-line border, aka focus rectangle. The focus rectangle then stays there until the window is closed. How can I prev...

Why does ItemsControl show a focus rectangle when its parent is focused?

WPF's ItemsControl will display a focus rectangle when it thinks it has focus and the user presses Tab or Alt. But I recently had an ItemsControl display a focus rectangle even though it did not have focus -- one of its parents did. The ItemsControl was inside a UserControl, which was inside another UserControl that did have focus. Some...

How to make a button focus in a thread in C#

I need to make a button focus at the end of a thread. The Button.Focus() method does not seem to work. for exmaple: Button1_Click(object sender, EventArgs e) { Thread myThread = new Thread(theThread); myThread.Start(); } theThread() { ... Button2.Focus(); // does not seem to focus the button } However, if I put Button2.Fo...

Anyone have a good way to debug WPF focus?

I'm going to focus hell right now in my WPF application. Focus is jumping around between elements, and seemingly disappearing only to come up on another element when the tab key is repeatedly pressed. Is there a property I can bind a label on to or something that will simply just tell me what the heck the keyboard focus is latched on to...

Issue with WPF Focus

I have code that handles the LostFocus event of my controls. It validates the value and in some cases will enable a subsequent control. For instance, there might be a ComboBox that allows a user to select a country. The subsequent ComboBox allows the user to select a state. IF the currently selected country is not the USA, the state ...

How to get the active ChildWindow of an application that is not focused?

Hello, I need to get the Handler to the child Window of a certain application that is running. I have the main window handler, but I need to know which specific child window is active, in order to use the SendMessage/PostMessage. I finally managed to do this using the following code, using firefox: [DllImport("user32.dll")] st...

Firefox 3 window focus and blur

Hello, $(window).blur(function(){ windowFocus = false; }).focus(function(){ windowFocus = true; }); The problem is that in firefox 3, when I create a new tab, it does not lose windowFocus. Where as in ff2, ie7 it does lose. In ff3 it only loses window focus when i select another program. Anyone have a solution to this problem? ...

Mac OS X: Spawning a Ruby Tk window that has focus

I'm trying to spawn a Tk window from ruby script using ruby's Tk module. It works, but I cannot figure out a way to focus the spawned window. It's frustrating. If I run this code from terminal, as in $ruby screenup.rb the window spawns behind the terminal window. If I run as a shell script in Quicksilver, two windows spawn. One is t...

this.focus() does not work properly in Firefox

I am using an ExternalInterface call on activate from a flex application embedded within my html document. The call goes to a javascript function which does function documentFocus() { this.focus(); } Everything works like a charm, except that Firefox does not focus the document body 100%. It stops listening for onkeyup events (it st...

Undo journaling: focusing the control being undone

I'm writing an undo journal for my WPF data-entry screen, which will track changes across all the controls. When the user selects Undo, I want to not only revert the latest change, but put focus back in the control whose value is being reverted. I'm struggling with the best way to put that focus back. My ViewModel will be the part that ...