A Plain-text only editorGadget?

Just starting out? Need help? Post your questions and find answers here.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

A Plain-text only editorGadget?

Post 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
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: A Plain-text only editorGadget?

Post 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
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: A Plain-text only editorGadget?

Post by rsts »

Actually, Mr Fox, that was my initial approach (but I was unaware of the autoscroll capability :oops:, 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
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: A Plain-text only editorGadget?

Post 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 :wink:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: A Plain-text only editorGadget?

Post 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
Egypt my love
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: A Plain-text only editorGadget?

Post 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
I may look like a mule, but I'm not a complete ass.
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: A Plain-text only editorGadget?

Post by Arctic Fox »

Okay, now I understand :D
Thanks for clarifying this, srod.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: A Plain-text only editorGadget?

Post by rsts »

So many nice options to choose from.

Thanks to you both. :D

cheers
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: A Plain-text only editorGadget?

Post by DoubleDutch »

Have you not tried Scintilla?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: A Plain-text only editorGadget?

Post by rsts »

DoubleDutch wrote:Have you not tried Scintilla?
Not so far. I'm already in way over my head :D

But someday...

cheers
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: A Plain-text only editorGadget?

Post 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.
I may look like a mule, but I'm not a complete ass.
User avatar
Hyper
User
User
Posts: 11
Joined: Sat May 23, 2009 10:40 am

Re: A Plain-text only editorGadget?

Post 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
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: A Plain-text only editorGadget?

Post 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?
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: A Plain-text only editorGadget?

Post by rsts »

The editorGadget, at least under windows, is reasonably complete rtf capable (I'm not sure of the exact RTF specs).

cheers
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Re: A Plain-text only editorGadget?

Post 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 
Post Reply