Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TRichEdit - OnMouseUp & OnSelectionChange

31 views
Skip to first unread message

Paulo Caetano

unread,
May 2, 2000, 3:00:00 AM5/2/00
to
Hello, everybody!

I've already searched the Web and Deja.com, but I've found no answer.

I have two questions about TRichEdit:
1. The OnSelectionChange Event. This event fires twice. Anyone knows
what's causing the second firing of the event?
2. The OnMouseUp Event never fires.

I can easily solve question #1 - AFAI could see, it consistently fires
twice every time, so a flag should do the trick, I guess. I would like
to understand why it's happening, though. Yes, I know... too curious for
my own good :)

OTOH, question #2 has eluded me completely. The problem seems to be with
TCustomRichEdit, because TMemo - which, like TCustomRichEdit, inherits
from TCustomMemo - handles the OnMouseUp Event correctly.

Any ideas, pointers, etc?

TIA!
--
Suravye ninto manshima taishite
Paulo Caetano

Please, remove "_your_mask_" to answer by e-mail

"And in the end the love you take is equal to the love you make"
Lennon & McCartney

Peter Below (TeamB)

unread,
May 2, 2000, 3:00:00 AM5/2/00
to
In article <390E8C4D...@tmn.pt>, Paulo Caetano wrote:
> I have two questions about TRichEdit:
> 1. The OnSelectionChange Event. This event fires twice. Anyone knows
> what's causing the second firing of the event?

It only fires twice when you click in the control, if you move the caret
using the keyboard to select it it will fire once per character the
selection grows or shrinks by. If you drag the mouse to select text the
event fires twice when you let go of the mouse, same as if you click. MS
may have had a reason for doing it this way but it is hidded to us mere
mortals <g>.

> 2. The OnMouseUp Event never fires.

That is not quite true, it fires if you mouse down on selected text and
then let go. This seems to be a side effect of the ability to drag text
around in the control (it natively supports OLE drag and drop).

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!


Paulo Caetano

unread,
May 3, 2000, 3:00:00 AM5/3/00
to
Thank you for your help, Peter. My research wasn't as complete as I
thought <sigh>.

I'm trying to do a chord file editor, and I want to allow the user to
select a note and a chord type on a toolbox, and insert it in the rich
edit (I'm using a rich edit because I've learned by experience that the
chords should be in bold).

The user would select the chord, click+ctrl on the rich edit, et voila!
The app inserts the chord. I will use OnMouseDown if I have to, but the
"right thing" seems to be OnMouseUp; it would work like a click on a
button, in that the button doesn't do anything if you don't until you
release the mouse button.

Any suggestion would be welcome :)

Thanks again!

Peter Below (TeamB)

unread,
May 3, 2000, 3:00:00 AM5/3/00
to
In article <390FE932...@tmn.pt>, Paulo Caetano wrote:
> The user would select the chord, click+ctrl on the rich edit, et voila!
> The app inserts the chord.
>
I would consider that a bit counterintutive. In a text editor you move
the caret to the place your want to insert text and then type. The
equivalent in your case would be to click on the chord and directly have
it inserted into the rich edit at the caret position (assign it to the
SelText property). That would allow much faster composition since the
mouse needs not move away from the chord list.

Paulo Caetano

unread,
May 4, 2000, 3:00:00 AM5/4/00
to
Peter Below (TeamB) wrote:
>
> In article <390FE932...@tmn.pt>, Paulo Caetano wrote:
> > The user would select the chord, click+ctrl on the rich edit, et voila!
> > The app inserts the chord.
> >
>
> I would consider that a bit counterintutive. In a text editor you move
> the caret to the place your want to insert text and then type. The
> equivalent in your case would be to click on the chord and directly have
> it inserted into the rich edit at the caret position (assign it to the
> SelText property). That would allow much faster composition since the
> mouse needs not move away from the chord list.

Well, now that you mention it... :)

I was considering what would be the "most productive" way of doing it.
To me, it's definitely selecting a chord, and "pasting" all its
instances on the file (similar to the Delphi IDE, when you Shift+click a
component). However, your combination of keyboard to move the caret and
mouse to insert the chord is a great option, too. Back to the drawing
board to find out a way to implement both; hopefully, a way that's not
confusing.

Yesterday I came across a wonderful component library called RXLib. I'm
using its RichEdit component. It handles the MouseUp event in a
predictable manner, although its SelectionChanged isn't so predictable.

Thank you, Peter.

0 new messages