[Gambas-user] Copying large string from javascript procedure

Safiur Rahman isafiur at gmail.com
Wed Jul 20 18:04:06 CEST 2022


The project is attached here

On Wed, Jul 20, 2022 at 9:42 PM Safiur Rahman <isafiur at gmail.com> wrote:

> Hi
>
> Is there a way to copy large string from javascript function (in
> gb.web.gui) so that it can be used elsewhere.
>
> Currently only few controls (eg. WebTextBox) can be filled from
> javascript procedure. However, WebTextBox is not able to hold large
> data (eg. from image).
>
> Case:1 (works fine)
>
> Public Sub WebButton5_Click()
>
>   WebForm._AddJavascript("var xdata = 'abcdef'")
>   WebForm._AddJavascript("$_(" & JS(WebTextBox1.Name & ":entry") &
> ").value = xdata")
>   WebForm._AddJavascript("gw.update(" & JS(WebTextBox1.Name) & ",
> 'text', xdata);")
>
> End
> -> string shown in WebTextBox
>
>
> Public Sub WebButton4_Click()
>
>   WebHtml1.Html = WebTextBox1.Text
>
> End
> -> "abcdef" is displayed in WebHtml
>
>
>
> Case:2 (doesn't work fine)
>
> Public Sub _new()
>
>   Me.AddJavascriptFile("js/sketchpad.js")
>   ''https://github.com/tsand/responsive-sketchpad
>
> End
>
> Public Sub WebContainer1_Render()
>
>   WebForm._AddJavascript("var pad = new Sketchpad($_(" &
> JS(WebContainer1.Name) & "), { line: {color: '#f44335', size: 1}});")
>
> End
>
>
> -> Now I draw on the screen
>
>
> Public Sub WebButton1_Click()
>
>   WebForm._AddJavascript("var xdata = pad.canvas.toDataURL(\"image/png\")")
>   WebForm._AddJavascript("$_(" & JS(WebTextBox1.Name & ":entry") &
> ").value = xdata")
>   WebForm._AddJavascript("gw.update(" & JS(WebTextBox1.Name) & ",
> 'text', xdata);")
>
> End
> -> Image data string shown in WebTextBox
>
>
> Public Sub WebButton4_Click()
>
>   WebHtml1.Html = WebTextBox1.Text
>
> End
> -> image data string is not shown in WebHtml
>
> Question: Is there any way to show the image data string to any
> WebControl which can be copied and used elsewhere in other procedures?
>
> (Attached a project to reproduce the problem. Please rename
> js/sketchpad.txt to js/sketchpad.js)
>
> --
> Regards
> Safiur Rahman
>


-- 
Regards
Safiur Rahman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220720/79ba55ea/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: webdata.zip
Type: application/zip
Size: 18555 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220720/79ba55ea/attachment-0001.zip>


More information about the User mailing list