setfocus

requestFocus() returning false

本小妞迷上赌 提交于 2019-12-22 08:22:41
问题 I am inflating a view when a button is pressed. The inflated view is like a dialog box, however when I try to get focus on the dialog box with requestFocus() , requestFocus() returns false means I am not getting focus on the view, but when I manually tap the inflated view, it recieves focus. What am I doing wrong? I clear focus from the button (which is used to inflated the new view) before I call requestFocus on inflated view. Regards 回答1: A possible reason why the View.requestFocus() method

Setting focus on a button is not working

无人久伴 提交于 2019-12-22 02:04:08
问题 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 == 13) { e.preventDefault(); $("#button").focus(); // Not working? } }); 回答1: Microsoft decided that they don't like e.keyCode and instead have their own syntax, e.which . You have to check for both: $("input.Box").live('keydown', function(e) { var

.focus() “set focus on a target input” will not work in Firefox

霸气de小男生 提交于 2019-12-21 21:22:10
问题 I have an input field. Under certain conditions I want to keep the user focused on the input field when they hit the Tab key. Basically I'm mimicking the functionality of Google's auto populating search box. I have everything working fine in every browser except the one I never have problems with... Firefox!? The following code works as expected in IE, Chrome and Safari, if you Tab out of the textbox with class myInput, your focus stays in the textbox. But in Firefox, when you Tab out of the

Focus lost on partial postback with UserControls inside UpdatePanel

妖精的绣舞 提交于 2019-12-20 03:08:37
问题 I have a bunch of user controls on a form inside an AJAX UpdatePanel, containing a couple of controls including a TextBox. Each of these usercontrols makes up a field on a data entry form. Some of the fields have AutoPostBack turned on and fire an event which updates the value in another form field server-side. However, when the partial postback returns and the calculated field is updated, the form focus is lost - the first field on the form gets focus back. Therefore the form is pretty

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

我只是一个虾纸丫 提交于 2019-12-18 04:33:07
问题 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 tried. SetFocus(this.loginForm.FindControl("UserName")); And TextBox tbox = (TextBox)this.loginForm.FindControl("UserName"); if (tbox != null) { tbox.Focus(); } // if 回答1: Are you using a ScriptManager on the Page? If so, try the following: public void

How to set Focus to a WPF Control using MVVM?

限于喜欢 提交于 2019-12-17 16:22:49
问题 I am validating user input in my viewmodel and throwing validation message in case validation fails for any of values. I just need to set the focus to the particular control for which validation has failed. Any idea how to achieve this ? 回答1: Generally, when we want to use a UI event while adhering to the MVVM methodology, we create an Attached Property : public static DependencyProperty IsFocusedProperty = DependencyProperty.RegisterAttached("IsFocused", typeof(bool), typeof

KeyCode_Enter to next edittext

怎甘沉沦 提交于 2019-12-17 15:54:27
问题 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 <EditText android:id="@+id/txtNPCode" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="18sp" android:layout_alignLeft="@+id/lblNPCode" android:layout_below="@+id/lblNPCode" android:layout_centerHorizontal="true"/> <EditText android:id="@+id/txtCNPCode" android:layout_width="fill_parent" android

Set keyboard focus to a <div>

六月ゝ 毕业季﹏ 提交于 2019-12-17 04:55:10
问题 I have the following code snippet: <div id="listbox1div" style="z-index:95; background:white; overflow-y:auto; overflow-x:hidden; width:240; height:314px;"> <a id="focusLink2"></a> <table id="ptObj_listbox1... I have a page that is building <div> elements dynamically (such as above). This <div> displays data on top of the main screen. When the page generates the divs I would like to set focus. I can not put an onLoad function on the body tag as I don't know when the divs will be generated. A

Set focus back to its parent?

爷,独闯天下 提交于 2019-12-14 03:51:39
问题 From post WPF: How to programmatically remove focus from a TextBox, I know how to set a TextBox 's focus back to its parent using the following code: // Move to a parent that can take focus FrameworkElement parent = (FrameworkElement)textBox.Parent; while (parent != null && parent is IInputElement && !((IInputElement)parent).Focusable) { parent = (FrameworkElement)parent.Parent; } DependencyObject scope = FocusManager.GetFocusScope(textBox); FocusManager.SetFocusedElement(scope, parent as

Giving focus back to main form

喜夏-厌秋 提交于 2019-12-12 15:53:32
问题 I have a C# app with two forms. The first one is the main form which should always be open. The second one is a preview pane which the user can enable. When the user selects to show the preview pane (menu option), the preview pane gets opened. Which is what I want. However I want to prevent the preview pane from ever getting the focus. Otherwise if users want to access to menu (which is on the main form) they first click and it looks like nothing is happening (but in fact the focus switches