My Notepad Style Project

Jan Schenkel janschenkel at yahoo.com
Fri Aug 1 07:43:31 EDT 2008


--- H Baric <hbaric at gmail.com> wrote:
> Hi all, this is my first post. Hope it works!
> 
> I'm making a very simple Text File Editor, based
> pretty much exactly on Window's Notepad, for the
> sake of learning.
> 
> I've been trying to find a way to set the Edit field
> to non-formatted text when copying and pasting text
> from web-pages and other applications for example. 
> 
> What would be the best way to ensure that the
> editing field cannot be formatted in any way (like
> Notepad and other basic text editors)? 
> 
> Is it possible? How (and where) would I script this?
> Thanks in advance :)
> 
> Cheers, 
> Heather
> 

Hi Heather,

Welcome to the Revolution community - you'll be sure
to receive lots of help as you're getting to know the
product we all love.

The one-line solution to strip the style information
from a text field is:
put the text of field "MyField" into field "MyField"

Now, if you want this to happen whenever the user
pastes more text into a field or drags-and-drops from
another field or another application, you'd have a
script similar to this:
##
on pasteKey
  send "StripStyles" to me in 0 milliseconds
  pass pasteKey
end pasteKey
on dragDrop
  send "StripStyles" to me in 0 milliseconds
  pass dragDrop
end dragDrop
on StripStyles
  -- save the current selection
  put the selectedChunk of me into tSelectedChunk
  -- strip the style information
  put the text of me into me
  -- restore the selection
  select tSelectedChunk
end StripStyles
##

Hope this helped,

Jan Schenkel.

Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


      



More information about the use-livecode mailing list