Page 1 of 1
Difficulty with Editor Gadget
Posted: Sun Feb 23, 2025 12:58 am
by coco2
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
Posted: Sun Feb 23, 2025 1:58 am
by BarryG
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
Posted: Sun Feb 23, 2025 3:07 am
by coco2
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
Posted: Sun Feb 23, 2025 3:13 am
by AZJIO
1. Enable RTF
Code: Select all
SendMessage_(GadgetID(0), #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
2. Set the font size in the gadget
Re: Difficulty with Editor Gadget
Posted: Sun Feb 23, 2025 3:18 am
by coco2
Hi AZJIO,
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
Posted: Sun Feb 23, 2025 4:05 am
by BarryG
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?
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).
[Edit] I was correct after all, per your linked image further below.
Re: Difficulty with Editor Gadget
Posted: Sun Feb 23, 2025 4:13 am
by coco2
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
Posted: Sun Feb 23, 2025 5:36 am
by AZJIO
coco2 wrote: Sun Feb 23, 2025 4:13 am
remove all
rich text formatting
What version of PureBasic are you using? In recent versions, RTF is disabled by default.
Re: Difficulty with Editor Gadget
Posted: Sun Feb 23, 2025 5:47 am
by coco2
I'm using 6.20
Here is what I'm talking about:
https://imgur.com/a/pKdceZC
Re: Difficulty with Editor Gadget
Posted: Sun Feb 23, 2025 6:16 am
by BarryG
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
Posted: Sun Feb 23, 2025 5:03 pm
by Axolotl
you can try this
Code: Select all
SetGadgetText(1, GetGadgetText(1)) ; <-- this does work on rtf
see this Testcode and press the buttons to see the differences.
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()
Re: Difficulty with Editor Gadget
Posted: Mon Apr 14, 2025 9:43 am
by PBJim
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
Posted: Mon Apr 14, 2025 9:43 am
by Fred
Yes.
Re: Difficulty with Editor Gadget
Posted: Mon Apr 14, 2025 10:21 am
by PBJim
Merci Fred, pour la réponse rapide. Thank you, Jim.