focus

How to focus a datatemplated TextBox in the first element of an ItemsControl in a Window, when the Window is opened? (C#, WPF)

六月ゝ 毕业季﹏ 提交于 2020-01-02 06:23:20
问题 When the user clicks a button in the application, a window opens up. I want the TextBox belonging to the first item in the ItemsControl to be focused, so that the user can start typing as soon as the Window is opened, without needing to manually select the TextBox. How can this be done? For simplicity, we can say that the Window looks approximately like this: <Window> <Grid> <ItemsControl ItemsSource="{Binding MyItems}"> <DataTemplate> <Grid> <StackPanel> <StackPanel> <customControls

Difference between Control.Focus() and FocusManager.SetFocusedElement()

巧了我就是萌 提交于 2020-01-02 05:47:09
问题 Literally, I want to know that. In some case, .Focus() appear better than SetFocusedElement(). But another case, it's reversal. So I must know what's different things are there. Additionally, by MSDN, .Focus() is for keyboard focus, and SetFocusedElement is for logical focus. But I can't feel different thing between logical focus and keyboard focus. 回答1: The keyboard focus is generally easier to understand, as that is effectively the control that would receive keyboard input if the user typed

How to give focus to default program of shell-opened file, from Java?

假装没事ソ 提交于 2020-01-02 05:25:12
问题 From within Java, I am opening an Excel file with the default file handler (MS Excel, in this case :-) ) using the method described in this stackoverflow question: Desktop dt = Desktop.getDesktop(); dt.open(new File(filename)); However, the Excel program doesn't get the focus. Is there any easy way to do so? Edit: There is a related stackoverflow question for C#, but I didn't find any similar Java method. Edit 2: I've did some simple tests, and discovered that Excel starts and gets the focus

What HTML elements are not tabbable even with tabindex?

爷,独闯天下 提交于 2020-01-02 05:08:55
问题 Does anyone have a list of the HTML (HTML5) elements that are not tabbable, even if a tabindex is specified? (By tabbable, I mean that they can receive the focus through repeatedly pressing the "tab" key.) We know that there are those elements which are tabbable by default, such as input or textarea . We also know that there are some elements which are only tabbable if a tabindex is explicitly specified, such as div and span elements. According to W3Schools, "In HTML5, the tabindex attribute

How to remove the focus of the back stack fragment?

社会主义新天地 提交于 2020-01-02 03:13:28
问题 I am using fragments in my application.I have a fragment that contains EditText and some Dialogfragment . When i click one particular widget it will move to next fragment. I need the first fragment in the backstack,so i added addToBackStack method also. The second fragment doesn't contain any EditText . Now the problem is, when we touch or press the second fragment, EditText in the first fragment get the focus and the dialogs are coming. I got the following code getView()

UIButton on different Y level can't be focused on tvOS

守給你的承諾、 提交于 2020-01-02 01:19:26
问题 I started developing apps for Apple TV and I have this problem whit buttons. I have a screen where are several buttons on bottom of the screen and then there is one, which is in the middle (see screenshot to understand). The problem is that I can't get focused the middle button. Focus is only on bottom three buttons. The problem is obviously caused by the Y position , when I move the button on bottom of the screen, it gets focused. Buttons are created in storyboard, there is no code in

Check whether some element is “focused” without jQuery

让人想犯罪 __ 提交于 2020-01-01 11:06:11
问题 I was almost sure I could find the answer here, but I wasn't successful. How would you check whether is there some object selected (focused) on the moment of the event call? I tried if (document.activeElement == "[object HTMLBodyElement]") , but apparently the .activeElement is being filled onLoad. I am not allowed to use jQuery, only mootools. Thanks a lot for the help! 回答1: https://developer.mozilla.org/en/DOM/document.activeElement - as pointed out, if no element is focused, the document

Check whether some element is “focused” without jQuery

℡╲_俬逩灬. 提交于 2020-01-01 11:04:04
问题 I was almost sure I could find the answer here, but I wasn't successful. How would you check whether is there some object selected (focused) on the moment of the event call? I tried if (document.activeElement == "[object HTMLBodyElement]") , but apparently the .activeElement is being filled onLoad. I am not allowed to use jQuery, only mootools. Thanks a lot for the help! 回答1: https://developer.mozilla.org/en/DOM/document.activeElement - as pointed out, if no element is focused, the document

jQuery clear input text on focus

我是研究僧i 提交于 2020-01-01 08:43:29
问题 I have this jQuery script: $(document).ready(function() { $(':input:enabled:visible:first').focus(); $('.letters').keyup( function() { var $this = $(this); if($this.val().length > 1) $this.val($this.val().substr(0, 1)); $(this).next('input').focus(); }); }); It will set focus on the first input='text' field on page load. When a user enters a character it will move focus to the next following input field. It will also limit the number of characters allowed in each field (currently 1 character)

jQuery clear input text on focus

ぐ巨炮叔叔 提交于 2020-01-01 08:43:25
问题 I have this jQuery script: $(document).ready(function() { $(':input:enabled:visible:first').focus(); $('.letters').keyup( function() { var $this = $(this); if($this.val().length > 1) $this.val($this.val().substr(0, 1)); $(this).next('input').focus(); }); }); It will set focus on the first input='text' field on page load. When a user enters a character it will move focus to the next following input field. It will also limit the number of characters allowed in each field (currently 1 character)