如何在corona sdk中从CK编辑器中检索数据

How to retrieve data from CK Editor in corona sdk?

本文关键字:编辑器 检索 数据 CK 中从 corona sdk      更新时间:2023-09-26

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

您不能直接执行此操作,因为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 )