如何从 corona sdk 中的 CK Editor 检索数据?

How to retrieve data from CK Editor in corona sdk?

我在 html 页面中嵌入了 CK 编辑器。现在我无法访问我的 lua 代码中 CK 编辑器文本区域中键入的数据。有什么方法可以检索 corona 中的数据吗?

您不能直接执行此操作,因为 Corona Webview 的方法有限。但是,您可以进行 HTTP 调用并自己分离数据(编辑器数据是否随调用一起提供)。我已经在其他网站上这样做以获取货币价格。您可以在下面看到我如何调用 moneymex 网站,然后根据我知道存在的模式分隔字符串。

  secondField = display.newText( "Touch to Start", 155, 155, native.systemFontBold, 16 )
secondField:setFillColor( 1 )

local function networkListener( event )
      --local alert = native.showAlert( "Corona", "Crap", { "OK"} )
    if ( event.isError ) then
           local alert = native.showAlert( "Corona", event.response, { "OK"} )
    else
    local pattern = ">%d%d,%d%d%d<"
    local buyPrice = string.sub(event.response, string.find(event.response, pattern))
      -- local alert = native.showAlert( "Corona", string.sub(buyPrice, 2, -2), { "OK"} )
      local junkLength = string.len(event.response);
      local sellJunk = string.find(event.response, pattern)
        local  sellPriceJunk= string.sub(event.response, sellJunk+50, sellJunk-junkLength+1000)
        local sellPrice = string.sub(sellPriceJunk, string.find(sellPriceJunk, pattern))
secondField.text = string.sub(buyPrice,2,-2).." and "..string.sub(sellPrice,2,-2)

   local alert = native.showAlert( "Corona", string.sub(buyPrice,2,-2).." and "..string.sub(sellPrice,2,-2), { "OK"} )

end
end

network.request( "https://moneymex.com/Home/Welcome", "GET", networkListener )