WPF – Remove focus when clicking outside of a textbox

Rather than adding new control to window, I think you should give your Grid a name and react to the MouseDown event on your window, moving the focus to the Grid itself. Something like this: <Window x:Class=”WpfApplication1.Window1″ xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Title=”Window1″ Height=”412″ Width=”569″ MouseDown=”Window_MouseDown” Name=”window1″> <Grid ShowGridLines=”False” Background=”#01FFFFFF” KeyDown=”Grid_KeyDown” Name=”grid1″ Focusable=”True”> <TextBox Width=”120″ Margin=”117,61,0,0″ Name=”textBox1″ VerticalAlignment=”Top” … Read more

Correct way to focus an element in Selenium WebDriver using Java

The following code – element.sendKeys(“”); tries to find an input tag box to enter some information, while new Actions(driver).moveToElement(element).perform(); is more appropriate as it will work for image elements, link elements, dropdown boxes etc. Therefore using moveToElement() method makes more sense to focus on any generic WebElement on the web page. For an input box … Read more

How to prevent going to next row after editing a DataGridViewTextBoxColumn and pressing EnterKey?

I tried this for changing the Enter behaviour for your Grid by inheriting a customcolumn from Textbox column and overriding the below event protected override bool ProcessDialogKey(Keys keyData) { if (keyData == Keys.Enter) return base.ProcessDialogKey(Keys.Tab); else return base.ProcessDialogKey(keyData); } So instead of the Enter Key being sent it emulates the action for Tab which will … Read more

AlertDialog with EditText, open soft keyboard automatically with focus on EditText doesn’t work

Ok I managed to get it working: Builder builder = new Builder(this); final EditText input = new EditText(this); builder .setTitle(R.string.dialog_title_addsubject) .setMessage(R.string.dialog_addsubject) .setView(input) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String value = input.getText().toString(); if (input.getText().toString().trim().length() == 0) { Toast.makeText(Main.this, R.string.input_empty, Toast.LENGTH_SHORT).show(); } else { db.insertSubject(value); getData(); } InputMethodManager imm = (InputMethodManager) … Read more

How to highlight ImageView when focused or clicked?

You need to assign the src attribute of the ImageView a state list drawable. In other words, that state list would have a different image for selected, pressed, not selected, etc. – that’s how the Twitter App does it. So if you had an ImageView: <ImageView style=”@style/TitleBarLogo” android:contentDescription=”@string/description_logo” android:src=”https://stackoverflow.com/questions/4185930/@drawable/title_logo” /> The src drawable (title_logo.xml) would … Read more