WPF-MVVM: Setting UI control focus from ViewModel
Use the IsFocused Attached Property as suggested in the Answer here: Set focus on textbox in WPF from view model (C#) Then you can simply bind to a property in your viewmodel.
Use the IsFocused Attached Property as suggested in the Answer here: Set focus on textbox in WPF from view model (C#) Then you can simply bind to a property in your viewmodel.
To solve this problem what you have to do is first use setOnFocusChangeListener of that Edittext edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { Log.d(“focus”, “focus lost”); // Do whatever you want here } else { Log.d(“focus”, “focused”); } } }); and then what you need to do is … Read more
I think it’s a bug or a feature which tries to present the whole activity to you without obscuring it with the soft keyboard at first. I’ve searched once for information regarding that but unfortunately found nothing coming from a really reliable source. Anyway, to show the soft keyboard you can do this: EditText editText … Read more
The way you have used refs is not the most preferred way or else its not the best practice anymore . try some thing like this class MyClass extends React.Component { constructor(props) { super(props); this.focus = this.focus.bind(this); } focus() { this.textInput.current.focus(); } render() { return ( <div> <input type=”text” ref={(input) => { this.textInput = input; … Read more
If it makes you feel better (it makes me feel better) you can do this in Xaml using an attached property: http://msdn.microsoft.com/en-us/library/system.windows.input.focusmanager.focusedelement.aspx Anything you can do in codebehind you can do in Xaml if you know the tricks. Fortunately, you didn’t have to implement this trick – MS did it for you.
Set the CheckBox as focusable=”false” in your XML layout. Otherwise it will steal click events from the list view. Of course, if you do this, you need to manually handle marking the CheckBox as checked/unchecked if the list item is clicked instead of the CheckBox, but you probably want that anyway.
A mouse-click on a focusable element raises events in the following order: mousedown focus mouseup click So, here’s what’s happening: mousedown is raised by <a> your event handler attempts to focus the <textarea> the default event behavior of mousedown tries to focus <a> (which takes focus from the <textarea>) Here’s a demo illustrating this behavior: … Read more
You can use Node.contains native DOM method for this. el.contains(document.activeElement); will check if activeElement is a descendant of el. If you have multiple elements to check, you can use a some function to iterate.
If you want to not display the focus rectangle in any case you could set the FocusVisualStyle to null. <MyControl FocusVisualStyle=”{x:Null}” />
I think this is a feature of mobile Safari rather than a bug. In our work on FastClick, my colleagues and I found that iOS will only allow focus to be triggered on other elements, from within a function, if the first function in the call stack was triggered by a non-programmatic event. In your … Read more