Page 1 of 2
A Plain-text only editorGadget?
Posted: Sun Nov 22, 2009 6:00 pm
by rsts
Before I spend another entire day (or more) in MSDN and the RTF documentation, does anyone know if it's possible to specify an editorGadget as plain-text ONLY.
I'd like to use an editorGadget to allow the entry of text but I would prefer if the user not expect their output data to include any formatting that may have been entered e.g. via a command or "paste" or whatever.
I know i could plainText the data after entry, or disallow any rich text type commands at entry via callback, but would prefer if their were another, easier, method.
If there any API or other command, which will set the editor as accepting plainText only?
cheers
Re: A Plain-text only editorGadget?
Posted: Sun Nov 22, 2009 6:15 pm
by Arctic Fox
You can use a multiline StringGadget.
Code: Select all
OpenWindow(0, 100, 100, 300, 300, "")
StringGadget(0, 5, 5, 290, 290, "", #ES_AUTOHSCROLL | #ES_MULTILINE | #WS_BORDER | #PB_String_BorderLess)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
Re: A Plain-text only editorGadget?
Posted: Sun Nov 22, 2009 6:34 pm
by rsts
Actually, Mr Fox, that was my initial approach (but I was unaware of the autoscroll capability

, so I had very limited entry (3 lines) - it's a small area)
I may need to use this, if there's no way to employ the editor.
Thanks once again.
cheers
Re: A Plain-text only editorGadget?
Posted: Sun Nov 22, 2009 6:57 pm
by Arctic Fox
Alternatively you can play with #EM_SETTEXTMODE and #TM_PLAINTEXT (though I can't make it work)
Stuff to spend another day anyway
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Re: A Plain-text only editorGadget?
Posted: Sun Nov 22, 2009 9:07 pm
by RASHAD
Hi rsts
Code: Select all
OpenWindow(0, 0, 0, 640,480, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget|#PB_Window_ScreenCentered)
;CreateWindowEx_(#WS_EX_CLIENTEDGE,"EDIT","", #WS_VISIBLE | #WS_CHILDWINDOW | #ES_AUTOHSCROLL |#ES_AUTOVSCROLL | #ES_MULTILINE | #ES_WANTRETURN |#ES_NOHIDESEL,50,50,300,300,WindowID(0),200,GetModuleHandle_(0),0)
CreateWindowEx_(#WS_EX_CLIENTEDGE,"EDIT","", #WS_VISIBLE | #WS_CHILDWINDOW | #WS_HSCROLL|#WS_VSCROLL| #ES_MULTILINE | #ES_WANTRETURN |#ES_NOHIDESEL,50,50,300,300,WindowID(0),200,GetModuleHandle_(0),0)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
Is that what you mean?
Check both types
Have a good day
Re: A Plain-text only editorGadget?
Posted: Sun Nov 22, 2009 10:02 pm
by srod
Arctic Fox wrote:Alternatively you can play with #EM_SETTEXTMODE and #TM_PLAINTEXT (though I can't make it work)
You need to clear the
text first - even though the control looks empty.
Code: Select all
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
hWnd = EditorGadget(0, 8, 8, 306, 133)
SetGadgetText(0, "")
SendMessage_(hWnd, #EM_SETTEXTMODE, #TM_PLAINTEXT, 0)
For a = 0 To 5
AddGadgetItem(0, a, "Line "+Str(a))
Next
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: A Plain-text only editorGadget?
Posted: Sun Nov 22, 2009 10:37 pm
by Arctic Fox
Okay, now I understand

Thanks for clarifying this,
srod.
Re: A Plain-text only editorGadget?
Posted: Sun Nov 22, 2009 11:40 pm
by rsts
So many nice options to choose from.
Thanks to you both.
cheers
Re: A Plain-text only editorGadget?
Posted: Mon Nov 23, 2009 1:50 am
by DoubleDutch
Have you not tried Scintilla?
Re: A Plain-text only editorGadget?
Posted: Mon Nov 23, 2009 2:12 am
by rsts
DoubleDutch wrote:Have you not tried Scintilla?
Not so far. I'm already in way over my head
But someday...
cheers
Re: A Plain-text only editorGadget?
Posted: Mon Nov 23, 2009 9:24 am
by srod
Scintilla is nice (if a bit quirky!

) I have just started using it myself and once you get used to it's api, it is really quite easy to use. I am about to release a wrapper which includes a fully customisable styling / code-folding lexer which you'd be welcome to use. Will probably release today.
Re: A Plain-text only editorGadget?
Posted: Tue Nov 24, 2009 5:37 pm
by Hyper
Hello,
I suppose, these 2 little functions are useful for you:
http://www.purebasic.fr/german/viewtopi ... =8&t=21039
Best wishes
Hyper
Re: A Plain-text only editorGadget?
Posted: Tue Nov 24, 2009 8:53 pm
by Foz
Pardon my ignorance, I thought that the editor gadget was just the multiline stringgadget.
If it's the rtf field in windows, what is it in the other operating systems?
Re: A Plain-text only editorGadget?
Posted: Tue Nov 24, 2009 9:14 pm
by rsts
The editorGadget, at least under windows, is reasonably complete rtf capable (I'm not sure of the exact RTF specs).
cheers
Re: A Plain-text only editorGadget?
Posted: Tue Aug 31, 2010 7:27 pm
by Nico
I have a problem with this code,unable to scroll down the page at the return, is it possible to do something?
Code: Select all
Texte.s="1"+Chr(13)+"2"+Chr(13)+"3"+Chr(13)+"4"+Chr(13)+"5"+Chr(13)+"6"+Chr(13)+"7"+Chr(13)
If OpenWindow(0, 0, 0, 300, 120, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
hWnd = EditorGadget(0, 10, 10, 280, 100)
SetGadgetText(0, "")
SendMessage_(hWnd, #EM_SETTEXTMODE, #TM_PLAINTEXT, 0)
SetGadgetText(0,Texte)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf