Selecting text on focus using jQuery not working in Safari and Chrome
It’s the onmouseup event that is causing the selection to get unselected, so you just need to add: $(“#souper_fancy”).mouseup(function(e){ e.preventDefault(); });
It’s the onmouseup event that is causing the selection to get unselected, so you just need to add: $(“#souper_fancy”).mouseup(function(e){ e.preventDefault(); });
Actually, guys, there is a way. I struggled mightily to figure this out for [LINK REMOVED] (try it on an iPhone or iPad). Basically, Safari on touchscreen devices is stingy when it comes to focus()ing textboxes. Even some desktop browsers do better if you do click().focus(). But the designers of Safari on touchscreen devices realized … Read more
You need to set FocusVisualStyle of each ListBoxItem to null. Steps are bellow 1) Create ItemContainerStyle for the ListBox <Style x:Key=”ListBoxItemStyle1″ TargetType=”{x:Type ListBoxItem}”> <Setter Property=”FocusVisualStyle” Value=”{x:Null}”/> …. 2) Set that style to Listbox <ListBox ItemContainerStyle=”{DynamicResource ListBoxItemStyle1}”
You could use the requestFocus tag: <Button …> <requestFocus /> </Button> I find it odd though that it auto-focuses one of your buttons, I haven’t observed that behavior in any of my views.
Old post but none of the solutions worked for me. I figured it out eventually though: var div = document.getElementById(‘contenteditablediv’); setTimeout(function() { div.focus(); }, 0);
In addtion you can use Focus widget. Focus( child: TextFormField(…), onFocusChange: (hasFocus) { if(hasFocus) { // do stuff } }, )
You can use the FocusManager.FocusedElement attached property for this purpose. Here’s a piece of code that set the focus to TxtB by default. <StackPanel Orientation=”Vertical” FocusManager.FocusedElement=”{Binding ElementName=TxtB}”> <TextBox x:Name=”TxtA” Text=”A” /> <TextBox x:Name=”TxtB” Text=”B” /> </StackPanel> You can also use TxtB.Focus() in your code-behind if you don’t want to do this in XAML.
It is explained in the Android Developers Blog: http://android-developers.blogspot.co.at/2008/12/touch-mode.html The following quotes should make it clear: By itself, the touch mode is something very easy to understand as it simply indicates whether the last user interaction was performed with the touch screen. For example, if you are using a G1 phone, selecting a widget with … Read more
Use this attributes in your layout tag in XML file: android:focusable=”true” android:focusableInTouchMode=”true” As reported by other members in comments it doesn’t works on ScrollView therefore you need to add these attributes to the main child of ScrollView.
Other posters have already explained why the :focus pseudo class is insufficient, but finally there is a CSS-based standard solution. CSS Selectors Level 4 defines a new pseudo class: :focus-within From MDN: The :focus-within CSS pseudo-class matches any element that the :focus pseudo-class matches or that has a descendant that the :focus pseudo-class matches. (This … Read more