Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text() didn't work for htmlarea #177

Open
coolit opened this issue Oct 4, 2018 · 1 comment
Open

Text() didn't work for htmlarea #177

coolit opened this issue Oct 4, 2018 · 1 comment
Labels
bug sciter-engine Issues related to the Sciter Engine itself

Comments

@coolit
Copy link

coolit commented Oct 4, 2018

The tiscript way worked, but Text() didn't . The test code is as follows:

package main

import (
	"log"

	"github.com/sciter-sdk/go-sciter"
	"github.com/sciter-sdk/go-sciter/window"
)

var html = `

<html>
    <head>
        <title>Test</title>
        <style>
		plaintext.simple > text { margin:0; padding:0; display:block; background:none; color:inherit;}

		</style>
        <script type="text/tiscript">

event click $(button#set) {
  $(#ha).value = "<p>this is <span style='background-color:#FFF18C'>test</span> for now.</p>";
}

event click $(button#gets) {
  var str = $(#ha).text;
  $(pre).value = str;
  stdout.println(str);
}
        </script>
    </head>
    <body>
<button#set>Set HTML</button>
<button#get>Get Text (Go)</button>
<button#gets>Get Text (Script)</button>

<htmlarea #ha>
  test
</htmlarea>

<pre/>

    </body>
</html>

`

func main() {
	w, err := window.New(sciter.SW_TITLEBAR|
		sciter.SW_RESIZEABLE|
		sciter.SW_CONTROLS|
		sciter.SW_MAIN|
		sciter.SW_ENABLE_DEBUG,
		nil)
	if err != nil {
		log.Fatal(err)
	}
	w.LoadHtml(html, "")
	w.SetTitle("Hello world")
	root, _ := w.GetRootElement()
	get, _ := root.SelectFirst("#get")
	get.OnClick(func() {
		ha, _ := root.SelectFirst("#ha")
		str, _ := ha.Text()
		//		str, _ := ha.Html(false)
		pre, _ := root.SelectFirst("pre")
		pre.SetHtml(str, 0)
	})

	w.Show()
	w.Run()
}
@pravic pravic added bug sciter-engine Issues related to the Sciter Engine itself labels Oct 31, 2018
@pravic
Copy link
Member

pravic commented Oct 31, 2018

@c-smile Reproduced with Go and Rust. Looks like a Sciter's issue.

The SciterGetElementTextCB returns empty text from the <htmlarea> if its value contains HTML markup (if it contains some plain text, it works well though). While on the script side the Element.text always returns plain text.

Element.text property:

For compound elements this property returns plain-text version of the content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug sciter-engine Issues related to the Sciter Engine itself
Development

No branches or pull requests

2 participants