如何从电晕SDK中的CK编辑器检索数据? [英] How to retrieve data from CK Editor in corona sdk?

查看:120
本文介绍了如何从电晕SDK中的CK编辑器检索数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have embedded the CK Editor in a html page. Now I am not able to access the data's that are typed in the CK Editor's text area in my lua code. Is there any way to retrieve the data in corona ?

推荐答案

您不能直接执行此操作,因为Corona Webview的方法有限.但是,您可以进行HTTP调用并自行分离数据(该调用附带了编辑器数据).我已经对其他网站进行了此操作以获取货币价格.您可以在下面看到我如何致电moneymex网站,然后根据我知道的模式分隔字符串.

You cant do this directly as Corona Webview has limited methods. However, you can make an HTTP call and separate the data yourself (is that editor data comes with the call). I have done this to other website to get currency prices. You can see below how I make a call to moneymex website and then separate the strings based on the pattern I know exists.

  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 )

这篇关于如何从电晕SDK中的CK编辑器检索数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆