Anitha Anitha - 2 years ago 138
Android Question

How to retrieve data from CK Editor in corona sdk?

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 ?

Answer Source

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"} )
    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"} )


network.request( "", "GET", networkListener )
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download