Copy-Pasting table into editorgadget

Just starting out? Need help? Post your questions and find answers here.
firace
Addict
Addict
Posts: 947
Joined: Wed Nov 09, 2011 8:58 am

Copy-Pasting table into editorgadget

Post 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 
Axolotl
Addict
Addict
Posts: 901
Joined: Wed Dec 31, 2008 3:36 pm

Re: Copy-Pasting table into editorgadget

Post by Axolotl »

I think, unfortunately, no.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
BarryG
Addict
Addict
Posts: 4272
Joined: Thu Apr 18, 2019 8:17 am

Re: Copy-Pasting table into editorgadget

Post 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.
Oso
Enthusiast
Enthusiast
Posts: 595
Joined: Wed Jul 20, 2022 10:09 am

Re: Copy-Pasting table into editorgadget

Post 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. :)
Post Reply