1. copy paste right click menu on RichEdit
- Posted by rubis at fem.unicamp.br
Feb 10, 2003
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
2. Re: copy paste right click menu on RichEdit
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!
3. Re: copy paste right click menu on RichEdit
> you have to create all the controls your self, and handle the menus and
stuff...
I tried using <CTRL+A> to select all and it worked, but I don't see where
that's handled in your code below... Or is this in Win32Lib? Or in the
Windows control itself?
> -- 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
4. Re: copy paste right click menu on RichEdit
Greg,
a simpler way of selecting all is ...
setIndex(RE, {1,0})
----------------
cheers,
Derek Parnell
----- Original Message -----
From: "Greg Haberek" <g.haberek at comcast.net>
To: "EUforum" <EUforum at topica.com>
Subject: Re: copy paste right click menu on RichEdit
>
> 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
<snip>
>
>
5. Re: copy paste right click menu on RichEdit
C.K.,
I use my selectAll() routine, but Derek just brought it to my attention that
setIndex( RE,
{1, 0}) works the same.. so where you see this:
elsif self = SelectAll then
selectAll(RE)
replace it with
elsif self = SelectAll then
setIndex( RE, {1,0} )
that is how everything is selected...
HTH,
~Greg
g.haberek at comcast.net
----- Original Message -----
From: Derek Parnell <ddparnell at bigpond.com>
To: EUforum <EUforum at topica.com>
Sent: Monday, February 10, 2003 4:07 PM
Subject: Re: copy paste right click menu on RichEdit
Greg,
a simpler way of selecting all is ...
setIndex(RE, {1,0})
----------------
cheers,
Derek Parnell
----- Original Message -----
From: "Greg Haberek" <g.haberek at comcast.net>
To: "EUforum" <EUforum at topica.com>
Sent: Tuesday, February 11, 2003 6:00 AM
Subject: Re: copy paste right click menu on RichEdit
>
> 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
<snip>
>
>
TOPICA - Start your own email discussion group. FREE!
6. Re: copy paste right click menu on RichEdit
- Posted by rubis at fem.unicamp.br
Feb 11, 2003
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>
>
>
7. Re: copy paste right click menu on RichEdit
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!