Hi Warwound
I thought, I have understood this interface, but I'm sorry it doesn't work.
I never got Control in the "CellClickHandler" nor I got a string of result.
In DBUtils I made a very small change of code. The Webview got an ID, for the Sub ExecuteHtml. This looks like this:
In my modul named DataEdit I made some definitions in Globals :
and in Activity_Create I made the activitations for the interfaces of WebViewSettings and the WebViewExtras. I also loaded the two librairis in my app.
In WebViewtable_OverrideUrl I got the values of row and col. And I used this comfort to get the value of this coordinates. And this looks like this:
Why did I never get the string "Wert" and why could I not work in the CellClickHandler? . What is wrong ? You are the producer of this Interface, perhaps you have an idea? I tested the Javascript in TryIt-Editor of W3School. And it worked perfectly.
Thanks a lot in advance. Greetings Anne.
I thought, I have understood this interface, but I'm sorry it doesn't work.
I never got Control in the "CellClickHandler" nor I got a string of result.
In DBUtils I made a very small change of code. The Webview got an ID, for the Sub ExecuteHtml. This looks like this:
B4X:
Sub ExecuteHtml(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, Clickable As Boolean) As String
...
sb.Append("<table id='WebView'><tr>").Append(CRLF)
...
In my modul named DataEdit I made some definitions in Globals :
B4X:
Sub Globals
Dim WebViewSettings1 As WebViewSettings
Dim WebViewExtras1 As WebViewExtras
Dim webViewTable As WebView
and in Activity_Create I made the activitations for the interfaces of WebViewSettings and the WebViewExtras. I also loaded the two librairis in my app.
B4X:
Sub Activity_Create(FirstTime As Boolean)
..
WebViewSettings1.setDefaultFontSize (webViewTable, 11)
WebViewExtras1.addJavascriptInterface(webViewTable, "B4A")
..
In WebViewtable_OverrideUrl I got the values of row and col. And I used this comfort to get the value of this coordinates. And this looks like this:
B4X:
Sub WebViewtable_OverrideUrl (Url As String) As Boolean
Dim values() As String
Dim col, row As Int
Dim HtmlCode As String
Dim Script As String
values = Regex.Split("[.]", Url.SubString(7))
col = values(0)
row = values(1)
Script = "B4A.CallSub('CellClickHandler', true, " & _
"document.getElementById('WebView').rows[" & row & "].cells[" & _
"col & "].innerHTML;"
Log(Script)
WebViewExtras1.executeJavascript(webViewTable,Script)
Return True 'Don't try to navigate to this URL
End Sub
Sub CellClickHandler(Wert As String)
Log(Wert)
End Sub
Why did I never get the string "Wert" and why could I not work in the CellClickHandler? . What is wrong ? You are the producer of this Interface, perhaps you have an idea? I tested the Javascript in TryIt-Editor of W3School. And it worked perfectly.
Thanks a lot in advance. Greetings Anne.
Last edited: