Difficulty with Editor Gadget
Difficulty with Editor Gadget
I have an editor gadget and I can change the font size in it using a button to make the font bigger or smaller. The problem I'm having is that if I type something with small text for example, then copy the small text, then make the font size bigger and paste in what I copied, it pastes in the smaller text. How can I make the editor gadget only paste in the same size text as what it's set to?
Re: Difficulty with Editor Gadget
Copying and pasting rich text always uses how it was copied, so this is normal (see WordPad, Word, etc). You can't change it to what the font size currently is because it hasn't been copied that way.
Re: Difficulty with Editor Gadget
I didn't know it was rich text. The help doesn't say anything about rich text. How would you even use rich text in it?
Re: Difficulty with Editor Gadget
1. Enable RTF
2. Set the font size in the gadget
Code: Select all
SendMessage_(GadgetID(0), #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
Code: Select all
SetGadgetFont(#Gadget , FontID)
Re: Difficulty with Editor Gadget
Hi AZJIO,
How do you disable Richtext in the gadget?
I tried this but it didn't work:
How do you disable Richtext in the gadget?
I tried this but it didn't work:
Code: Select all
SendMessage_(GadgetID(#edtInput), #EM_SETTEXTMODE, #TM_PLAINTEXT, 0)
Re: Difficulty with Editor Gadget
Oh, I mistakenly assumed it was because you mentioned the different font size, and I thought you meant the editor had different font sizes in it for different parts of its text (your button comment made me think that).coco2 wrote: Sun Feb 23, 2025 3:07 amI didn't know it was rich text. The help doesn't say anything about rich text. How would you even use rich text in it?
[Edit] I was correct after all, per your linked image further below.
Last edited by BarryG on Sun Feb 23, 2025 6:18 am, edited 1 time in total.
Re: Difficulty with Editor Gadget
I may not have been clear, I'm trying to remove all rich text formatting from the editor gadget, but not having any luck.
Re: Difficulty with Editor Gadget
What version of PureBasic are you using? In recent versions, RTF is disabled by default.
Re: Difficulty with Editor Gadget
Yeah, that looks like rich text to me, because there's two different font sizes. So I was right in my initial comment.
Re: Difficulty with Editor Gadget
you can try this
see this Testcode and press the buttons to see the differences.
Code: Select all
SetGadgetText(1, GetGadgetText(1)) ; <-- this does work on rtf
Code: Select all
; tested with PB 6.11 x64
Global rtf_text.s = "" +
"{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1031{\fonttbl{\f0\fnil\fcharset0 Calibri;}} " +
"{\*\generator Riched20 10.0.19041}\viewkind4\uc1 " +
"\pard\sa200\sl276\slmult1\f0\fs22\lang7 Test with \fs32 different \fs22 Fonts. \par " +
"} "
Procedure Main()
If OpenWindow(0, 0, 0, 322, 340, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 8, 8, 306, 133) ; plain
SendMessage_(GadgetID(0), #EM_SETTEXTMODE, #TM_PLAINTEXT, 0)
EditorGadget(1, 8, 133+16, 306, 133) ; rtf
SendMessage_(GadgetID(1), #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
ButtonGadget(2, 8, 310, 76, 20, "Plain")
ButtonGadget(3, 88, 310, 76, 20, "RTF")
SetGadgetText(0, rtf_text) ; <-- this does not work this way
SetGadgetText(1, rtf_text) ; <-- with formatting
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case 2
SetGadgetText(0, GetGadgetText(1)) ; <-- this does work on plain
Case 3
SetGadgetText(1, GetGadgetText(1)) ; <-- this does work on rtf
EndSelect
EndSelect
ForEver
EndIf
EndProcedure
End Main()
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).
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).
Re: Difficulty with Editor Gadget
Can anyone confirm, was there definitely a change after PB 6.00 that requires #TM_RICHTEXT to be set, in order to display RTF content? It wasn't necessary on PB 6.00 (Windows 64-bit).
Code: Select all
editor.i = EditorGadget(#PB_Any, 10, 10, 360, 250, #PB_Editor_ReadOnly | #PB_Editor_WordWrap)
SendMessage_(GadgetID(editor.i), #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
Re: Difficulty with Editor Gadget
Merci Fred, pour la réponse rapide. Thank you, Jim.