mk-soft wrote: Thu May 16, 2024 12:04 pm
Not a bug,
Nothing changes in the loaded HTML code. It is an edit field. To get to the entered data it is better to use the WebViewGadget and JScript.
Only the document view changes
It's like an edit field, but a user mutating
contenteditable elements does necessarily change the HTML.
The notion that
GetGadgetItemText() must return only the value set by a prior
SetGadgetItemText() is at odds with behaviour already exhibited by the
WebGadget, where data from
#PB_Web_HtmlCode is updated upon page navigation by the user. Similarly, for the
EditorGadget, the user may of course mutate (unless
#PB_Editor_ReadOnly) a programmatically set value and have changes be reflected with
GetGadgetItemText().
Besides debates over semantics and/or precedent, I'd say there is a potential bug here since behaviour is inconsistent with different
WebGadget() flags.
Given code like this:
Code: Select all
Define html.s = "<html>" +
"<body>" +
"<div contenteditable>" +
"Hello World! Edit this content." +
"</div>" +
"</body>" +
"</html>"
OpenWindow(#PB_Any, 0, 0, 600, 400, "Editable HTML Content", #PB_Window_SystemMenu)
Define btnGetHtml = ButtonGadget(#PB_Any, 8, 8, 100, 25, "Get HTML")
Define webEditor = WebGadget(#PB_Any, 0, 41, 600, 359, "")
SetGadgetItemText(webEditor, #PB_Web_HtmlCode, html)
Repeat
Define event = WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case btnGetHtml : MessageRequester("HTML:", GetGadgetItemText(webEditor, #PB_Web_HtmlCode))
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow
You can edit the content in the
<div> and it
won't be reflected when pressing the "Get HTML" button.
If you now change:
Code: Select all
Define webEditor = WebGadget(#PB_Any, 0, 41, 600, 359, "")
To:
Code: Select all
Define webEditor = WebGadget(#PB_Any, 0, 41, 600, 359, "", #PB_Web_Edge)
Changes to the
<div> will be reflected when pressing the "Get HTML" button.
This applies only for Windows of course.
This difference may be deliberate, to avoid breaking existing
WebGadget code which predates the Edge backing. If that is the case, hopefully it can be documented, so we know whether or not things should be expected to act this way.