Page 1 of 1

Copy-Pasting table into editorgadget

Posted: Fri Sep 29, 2023 1:13 pm
by firace
I don't really need this, but I was experimenting with copy-pasting a table from WordPad (RTF document) into an EditorGadget, which used to work fine in previous PB versions, but no longer works for some reason. When trying to paste the table, nothing is inserted at all.

I'm aware of a workaround (manually creating the richedit control using CreateWindowEx_), but is there a cleaner solution?

Code: Select all


OpenWindow(0,0,0,320,240,"") 

EditorGadget(1, 0, 0, 320, 240)

SendMessage_(GadgetID(1), #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
SetGadgetText(1, "")


Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 

Re: Copy-Pasting table into editorgadget

Posted: Fri Sep 29, 2023 4:45 pm
by Axolotl
I think, unfortunately, no.

Re: Copy-Pasting table into editorgadget

Posted: Sat Sep 30, 2023 1:31 am
by BarryG
Just tried it, and it's definitely a bug because I used to be able to paste rich text into an EditorGadget, too. Fonts, colors, styles, etc. But not with 6.03 B8 now, even with #TM_RICHTEXT set first.

Re: Copy-Pasting table into editorgadget

Posted: Sat Sep 30, 2023 6:22 am
by Oso
BarryG wrote: Sat Sep 30, 2023 1:31 am Just tried it, and it's definitely a bug because I used to be able to paste rich text into an EditorGadget, too. Fonts, colors, styles, etc. But not with 6.03 B8 now, even with #TM_RICHTEXT set first. It doesn't work if I use AddGadgetItem().
I can confirm the below works fine in PureBasic 6.00 Windows 64 but not if I use AddGadgetItem. Glad that you raised this @firace because I'd been looking for a way to format text.

Code: Select all

testwin.i = OpenWindow(#PB_Any, 0, 0, 800, 240, "RTF Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
testdsp.i = EditorGadget(#PB_Any, 0, 0, 800, 200, #PB_Editor_ReadOnly | #PB_Editor_WordWrap)

rtffil.i = ReadFile(#PB_Any, "\path\my_rtf_file.rtf")
If rtffil.i
  While Not Eof(rtffil.i)
    strwork.s = strwork.s + ReadString(rtffil.i)
  Wend
  CloseFile(rtffil.i)
  
  SetGadgetText(testdsp.i, strwork.s)
EndIf

testcls.i = ButtonGadget(#PB_Any, 714, 205, 80, 30, "Close", #PB_Button_Default)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow Or EventGadget() = testcls.i

CloseWindow(testwin.i)
EDIT: I realised afterwards that firace was referring primarily to pasting into the EditorGadget, rather than displaying RTF. No sure if displaying works for you in PB 6.03 etc. Apologies for the misunderstanding there. :)