How to retrieve data from CK Editor in corona sdk?

十年热恋 提交于 2019-12-14 03:35:11

问题


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 ?


回答1:


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 )


来源:https://stackoverflow.com/questions/37299538/how-to-retrieve-data-from-ck-editor-in-corona-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!