1

Thanks to this answer I know how to completely disable user selection on a WebView.

I would like to prevent users from selecting text/graphics in the WebView but still be able to select a text field to input text. With the above solution selecting text fields is not allowed.

Community
  • 1
  • 1
xizor
  • 1,554
  • 2
  • 16
  • 35

1 Answers1

0

It appears the changing the delegate to return [[proposedRange startContainer] isContentEditable] will allow selection on editable elements, i.e. form fields.

- (BOOL)webView:(WebView *)webView shouldChangeSelectedDOMRange:
    (DOMRange *)currentRange
    toDOMRange:(DOMRange *)proposedRange
    affinity:(NSSelectionAffinity)selectionAffinity
    stillSelecting:(BOOL)flag
{
    return [[proposedRange startContainer] isContentEditable];
}
usm
  • 245
  • 2
  • 17