Re: copy paste right click menu on RichEdit

new topic     » goto parent     » topic index » view thread      » older message » newer message

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>

>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu