Re: copy paste right click menu on RichEdit
- Posted by rubis at fem.unicamp.br Feb 11, 2003
- 466 views
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) > > end if <snip> > >