Re: copy paste right click menu on RichEdit
- Posted by Greg Haberek <g.haberek at comcast.net> Feb 11, 2003
- 510 views
It depends on what you're using it for. An MleText supports only one color of text, and only one font. A RichText supports multiple fonts and multiple colors. Also, keep in mind that if you are inserting text through your code into an MleText, each line must have a Carriage-Return and Line-Feed (CRLF = "\r\n") or else you'll end up with an unknown character. Also, RichText supports bitmap insertion (with a library), MleText does not. Search for 'Insert Bitmaps' in the archive to find it. I believe a few people have been working on fully-functional RichEdit libraries, but I'm not sure which are API-based and which are Win32Lib-based. I know I used Mario Steele's RichEdit Library a while ago, but I lost it in my X-mas crash (i woke up X-mas morning to find that windows would no longer boot, and I had 27 bad sectors on my hard drive), and the link in the archive doesn't work anymore. Oh well, poor me, I guess I should back-up more often! My Axiom editor uses Don Phillips' Syntax v1(found in xControls), which uses a RichText control. I've recently been having problems with it however, since I reinstalled windows (from my X-mas crash). I have a lot of work to do on that program, and less time to do it in. ~Greg g.haberek at comcast.net ----- Original Message ----- From: <rubis at fem.unicamp.br> To: EUforum <EUforum at topica.com> Sent: Tuesday, February 11, 2003 2:00 PM Subject: Re: copy paste right click menu on RichEdit Thanks Greg; So, after this, I have a new question: What are the differences between MleText and a RichEdit commands ? I just change the RichEdit to MleText in my program and solve the problem. It works almost similar for me. Rubens At 16:00 10/2/2003, you wrote: > >you have to create all the controls your self, and handle the menus and >stuff... >here is a demo: > >-- begin code -- >-- everything should be word-wrap safe! -- >include win32lib.ew > >-- this is a simple RichEdit demo showing how >-- to use the Popup box like that of an MleText >-- written by Greg Haberek >-- feel free to use any code here, >-- but please give credit if you use my selectAll() routine > >constant > > Main = create( Window, "RichEdit Demo", > 0, 0.16, 0.12, 0.64, 0.48, 0 ), > > RE = create( RichEdit, "", Main, 0, 0, 1, 1, 0 ), > > Popup1 = create( Popup, "RichEdit Menu", Main, > 0, 0, 0, 0, 0 ), > Undo = create( MenuItem, "&Undo", Popup1, > 0, 0, 0, 0, 0 ), > Sep1 = create( MenuItem, "-", Popup1, > 0, 0, 0, 0, 0 ), > Cut = create( MenuItem, "Cu&t", Popup1, > 0, 0, 0, 0, 0 ), > Copy = create( MenuItem, "&Copy", Popup1, > 0, 0, 0, 0, 0 ), > Paste = create( MenuItem, "&Paste", Popup1, > 0, 0, 0, 0, 0 ), > Delete = create( MenuItem, "&Delete", Popup1, > 0, 0, 0, 0, 0 ), > Sep2 = create( MenuItem, "-", Popup1, > 0, 0, 0, 0, 0 ), > SelectAll = create( MenuItem, "Select &All", Popup1, > 0, 0, 0, 0, 0 ) > >procedure selectAll( integer id ) >-- selects all text in a RichEdit >sequence text >integer len > text = getStream( id, StreamText ) > len = length(text) > if text[len] != '\n' then > -- if text is only one line, > -- the last character would not be highlighted > -- so select one more character > len +=1 > end if > setIndex( id, {1, len} ) >end procedure > >procedure Main_w32HResize( >integer self, integer event, sequence params ) >sequence rect > rect = getClientRect( Main ) > > setRect( RE, rect[1], rect[2], rect[3], rect[4], 1 ) > >end procedure >setHandler( {Main}, {w32HResize}, >routine_id("Main_w32HResize") ) > >procedure RE_w32HMouse( >integer self, integer event, sequence params ) > > if params[1] = RightDown then > popup( Popup1, params[2], params[3] ) > end if > >end procedure >setHandler( {RE}, {w32HMouse}, >routine_id("RE_w32HMouse") ) > >procedure SelectAll_w32HClick( >integer self, integer event, sequence params ) >sequence text > > if self = Undo then > undo(RE) > > elsif self = Cut then > cut(RE) > > elsif self = Copy then > copy(RE) > > elsif self = Paste then > paste(RE) > > elsif self = Delete then > clear(RE) > > elsif self = SelectAll then > selectAll(RE) > <snip> > > TOPICA - Start your own email discussion group. FREE!