focus

Focus on a TextBox in a DataTemplate

ぐ巨炮叔叔 提交于 2019-12-19 05:51:36
问题 I have DataTemplate containing a TextBox . I'm setting this template to a listbox item on a selection. I'm unable to set focus to textbox in the template. I tried to call MyTemplate.FindName, but it ends up with an Invalid Operation Exception: This operation is valid only on elements that have this template applied. How can I access it? 回答1: Since you know the name of the TextBox you want to focus, this becomes relatively easy. The idea is to get hold of the template as it's applied to the

Focus on a TextBox in a DataTemplate

跟風遠走 提交于 2019-12-19 05:51:06
问题 I have DataTemplate containing a TextBox . I'm setting this template to a listbox item on a selection. I'm unable to set focus to textbox in the template. I tried to call MyTemplate.FindName, but it ends up with an Invalid Operation Exception: This operation is valid only on elements that have this template applied. How can I access it? 回答1: Since you know the name of the TextBox you want to focus, this becomes relatively easy. The idea is to get hold of the template as it's applied to the

How do I get the element being edited?

时光总嘲笑我的痴心妄想 提交于 2019-12-19 05:09:06
问题 I'm developing a webapp, and I have a problem with the JavaScript. The following is a simplified version of the HTML causing the problem. I have some nested contenteditable divs (I replaced the real content with placeholder text): <div contenteditable="true" id="div1"> text <div contenteditable="inherit" id="div2"> text <div contenteditable="inherit" id="div3"> text </div> text </div> text </div> I want to get the element that's selected (being edited by the user) via JavaScript, but so far I

验证身份证/电话号码等

折月煮酒 提交于 2019-12-19 05:00:09
jQuery验证: test()方法 判断字符串中是否匹配到正则表达式内容,返回的是boolean值 ( true / false ) // 验证中文名称 function isChinaName(name) { var pattern = /^[\u4E00-\u9FA5]{1,6}$/; return pattern.test(name); } // 验证手机号 function isPhoneNo(phone) { var pattern = /^1[34578]\d{9}$/; return pattern.test(phone); } // 验证身份证 function isCardNo(card) { var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; return pattern.test(card); } // 验证函数 function formValidate() { var str = '' ; // 判断名称 if ($.trim($( '#name' ).val()).length == 0) { str += '名称没有输入\n' ; $( '#name' ).focus(); } else { if (isChinaName($.trim($( '#name' ).val())) ==

Find value in spreadsheet using google script

青春壹個敷衍的年華 提交于 2019-12-19 04:55:14
问题 Situation: 1 spreadsheet multiple sheets 1 cell selected (may vary) What I'd like to do is to find and set focus to the next cell in any sheet that matches the selected cell (case insensitive) upon clicking a button-like image in the spreadsheet. Sort of like a custom index MS Word can create for you. My approach is: - set value of the selected cell as the variable (succeeded) - find the first cell that matches that variable (not the selected cell) (no success) - set value of found cell as

Java JNA focus a specific Window

一世执手 提交于 2019-12-19 04:52:28
问题 I am trying to give my application the power to focus another Window (Notepad in this case) My Class is looking like this public static class Win32WindowUtils { public interface User32 extends StdCallLibrary { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS); HWND GetParent(HWND hWnd); HWND FindWindow(String lpClassName, String lpWindowName); HWND SetFocus(HWND hWnd); HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, String lpszClass,

WPF: Selecting all the text in and setting focus to a ComboBox's editable textbox

丶灬走出姿态 提交于 2019-12-19 04:05:55
问题 I have a WPF ComboBox which has its IsEditable property bound to a view model which can switch it on and off. When it is switched on, I want to give focus to the ComboBox and select all the text in the edit TextBox . I can't see the best to accomplish this. Should I replace the ControlTemplate , subclass the ComboBox base class, and provide the needed properties, use Attached Properties, or some other approach? 回答1: I have a solution for you. I'm using a combination of Model-View-ViewModel

how to force focus to edit text

北城余情 提交于 2019-12-19 03:15:33
问题 I read around about the questions on how to set an object to be focused however I cannot seem to find either an answer to what I am trying to do. Using the On Focus Listener I have done the following: Ehour.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View arg0, boolean arg1) { // TODO Auto-generated method stub if (!arg1) { if (Ehour.getText().length()<=0) { Toast.makeText(getApplicationContext(), "No Hour Entered", Toast.LENGTH_LONG).show();

Disable focus on fragment

非 Y 不嫁゛ 提交于 2019-12-19 02:54:08
问题 I'm working on application for TV platform and use RCU for navigation. I have use case where I have two fragments one above each other and visible on the screen at the same time. Is there a way to disable focusing fragment that is below? setFocusable(false) on fragments view doesnt work, and I'm able to focus elements in fragment below. Thanks in advance. 回答1: The solution that I've come up with in the end is: Added custom Lifecycle listeners for the fragment namely: onFragmentResume and

Uwp navigation example and focusing on control

我的未来我决定 提交于 2019-12-19 02:07:03
问题 I use uwp navigation example as an example for my application navigation. I need to set the focus on TextBox. I try it on uwp navigation example. For BasicPage I add this code: <StackPanel Orientation="Vertical"> <TextBox x:Name="Test" /> <TextBox x:Name="Test1" /> </StackPanel> public BasicPage() { this.InitializeComponent(); this.Loaded += BasicPage_Loaded; } private void BasicPage_Loaded(object sender, RoutedEventArgs e) { Test1.Focus(FocusState.Programmatic); } Test1 does not receive the