Re: copy paste right click menu on RichEdit
- Posted by Greg Haberek <g.haberek at comcast.net> Feb 10, 2003
- 511 views
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 end procedure setHandler( {SelectAll,Delete,Paste,Copy,Cut,Undo}, {w32HClick}, routine_id("SelectAll_w32HClick") ) WinMain( Main, Normal ) -- end code -- ----- Original Message ----- From: <rubis at fem.unicamp.br> To: EUforum <EUforum at topica.com> Sent: Monday, February 10, 2003 9:02 AM Subject: copy paste right click menu on RichEdit Hi people; How can I enable the right click menu (undo, cut, copy, paste...) popup in RichEdit commands ? crtl+c and crtl+v works, but I want the popup menu, like the one in EditText commands. thanks Rubens TOPICA - Start your own email discussion group. FREE!