I have a little progress to report, i have created the
SelectableWebView!
Sub Process_Globals
End Sub
Sub Globals
Dim SelectableWebView1 As SelectableWebView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.AddMenuItem("EnableSelection", "MenuItem")
SelectableWebView1.Initialize("SelectableWebView1")
Activity.AddView(SelectableWebView1, 0, 0, 100%x, 100%y)
SelectableWebView1.LoadUrl("http://www.b4x.com/forum/basic4android-updates-questions/14437-highlight-text-webview-long-tap-3.html#post99556")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub MenuItem_Click
SelectableWebView1.EnableSelectionMode
End Sub
Sub SelectableWebView1_SelectionReady(SelectedText As String)
Msgbox(SelectedText, "Selected text:")
End Sub
The SelectableWebView has just one method to look at:
EnableSelectionMode
Puts the WebView into text selection mode.
Run the project and use the Menu key to enable text selection mode - it all works fine i think.
Android automatically displays a Toast message
Text copied to clipboard - a search on Google shows that it's probably not possible to suppress that message.
You could get strange results if the user currently has text pasted into the Android clipboard or if they use the clipboard in another application while also using your application - i might be able to find a workaround for that.
And if you're happy with this selection method i'll need to add all the standard WebView methods to it - EnableSelectionMode and LoadUrl are it's only two methods at the moment.
An idea - when text selection mode is enabled, disable the web page javascript that hightlights text so as to not cause a conflict between highlighting and selection.
Demo code and alpha version of the library are attached, have a play and let me know if you want me to develop the new library further.
Martin.