Page 1 of 1

multiline string gadget with dialog library

Posted: Sun Oct 25, 2020 8:37 pm
by nsstudios
Hi,

I tried to convert my gadget code to dialog library, and I have a problem.
I use the following flags for my string gadgets:

Code: Select all

#ES_MULTILINE|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT|#ES_AUTOVSCROLL|#ES_AUTOHSCROLL| #WS_VSCROLL
Using them in the dialog xml results in an error, even if if I make them available through runtime.
Is there any way to still make string gadgets with dialog library with those flags?
I would use editor gadget, but it hooks the tab key, and all of the examples I've seen for disabling that behavior are for Windows only, and I'd still need the extra Windows flags anyway.

I'd really appreciate a solution to this problem.

Re: multiline string gadget with dialog library

Posted: Mon Oct 26, 2020 7:59 am
by RASHAD
There is noway to change the properties of the StringGadget() after creation
Next is a workaround
Remember to use id='?'

Code: Select all

EnableExplicit

Global dlg_window1 = CreateDialog(#PB_Any)
Global DialogsXML$ = #Empty$
DialogsXML$ +
   "<dialogs>" +
   "   <window name='window1' flags='#PB_Window_SystemMenu|#PB_Window_SizeGadget| #PB_Window_ScreenCentered'>" +
   "      <string name='editor1' id='0' width='200' height='100'/>" +
   "   </window>" +
   "</dialogs>"
Define DialogsXML = ParseXML(#PB_Any, DialogsXML$)
Define x,y,w,h

If OpenXMLDialog(dlg_window1, DialogsXML, "window1")
  Define editor = DialogGadget(dlg_window1, "editor1")
  x = GadgetX(editor)
  y = GadgetY(editor)
  w = GadgetWidth(editor)
  h = GadgetHeight(editor)
   FreeGadget(editor)
   StringGadget(editor,x,y,w,h,"",#ES_MULTILINE|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT|#ES_AUTOVSCROLL|#ES_AUTOHSCROLL| #WS_VSCROLL)
  ;SendMessage_(GadgetID(editor),#EM_SHOWSCROLLBAR, #SB_VERT,0)
  ;SendMessage_(GadgetID(editor),#EM_SHOWSCROLLBAR, #SB_HORZ,0)

  SetGadgetText(editor, ~"11111111111111111111111111111111\n22222222222222222222222222222222\n\n\n\n\n\n\n")
EndIf

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: multiline string gadget with dialog library

Posted: Mon Oct 26, 2020 8:25 am
by nsstudios
Good idea! Thanks.

Re: multiline string gadget with dialog library

Posted: Wed Apr 24, 2024 1:53 pm
by Quin
RASHAD wrote: Mon Oct 26, 2020 7:59 am There is noway to change the properties of the StringGadget() after creation
Next is a workaround
Remember to use id='?'

Code: Select all

EnableExplicit

Global dlg_window1 = CreateDialog(#PB_Any)
Global DialogsXML$ = #Empty$
DialogsXML$ +
   "<dialogs>" +
   "   <window name='window1' flags='#PB_Window_SystemMenu|#PB_Window_SizeGadget| #PB_Window_ScreenCentered'>" +
   "      <string name='editor1' id='0' width='200' height='100'/>" +
   "   </window>" +
   "</dialogs>"
Define DialogsXML = ParseXML(#PB_Any, DialogsXML$)
Define x,y,w,h

If OpenXMLDialog(dlg_window1, DialogsXML, "window1")
  Define editor = DialogGadget(dlg_window1, "editor1")
  x = GadgetX(editor)
  y = GadgetY(editor)
  w = GadgetWidth(editor)
  h = GadgetHeight(editor)
   FreeGadget(editor)
   StringGadget(editor,x,y,w,h,"",#ES_MULTILINE|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT|#ES_AUTOVSCROLL|#ES_AUTOHSCROLL| #WS_VSCROLL)
  ;SendMessage_(GadgetID(editor),#EM_SHOWSCROLLBAR, #SB_VERT,0)
  ;SendMessage_(GadgetID(editor),#EM_SHOWSCROLLBAR, #SB_HORZ,0)

  SetGadgetText(editor, ~"11111111111111111111111111111111\n22222222222222222222222222222222\n\n\n\n\n\n\n")
EndIf

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Hi there,
This works, except there is one problem with it. If you put a TextGadget above/below the field (for screen reader accessibility) it isn't read after you remove/recreate the gadget in this way :cry:
Is there any other way? I tried

Code: Select all

SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) | #ES_AUTOHSCROLL | #ES_MULTILINE | #ES_NOHIDESEL)
This half works. It tricks my screen reader into saying multiline and reporting the multiline role, but it doesn't actually let me paste or insert multiple lines.