TEdit Control and Font

General TRichView support forum. Please post your questions here
Post Reply
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

TEdit Control and Font

Post by BernhardRoos »

Hello,
what is the best way to set the Font property of a TEdit control each time if the TEdit is selected (perhaps there is some text selected and one or more TEdit controls at one time) in all selected TEdit controls. Is there an example to do this?

Best wishes
Bernhard
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You can use TRichViewEdit.OnSelect event. In this event, call GetSelectionBounds, enumerate all selected items and check if they contain TEdit.
As for other your questions, I need some time to answer them. I'll try to answer in
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

Post by BernhardRoos »

Sorry. It was a missunderstanding. I will try to explain my problem.

The user changes the font style, the font size, the font color or the font name of the selected items. Perhaps with the toolbar or with the menu Character.

Is there a way to react to such actions in one event. So I can use GetSelectionBounds for determing if there are controls selected.

OnSelect is not the right event.

Best wishes and thanks for your support
Bernhard
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

Post by BernhardRoos »

I've found a way. In RVAControlPanel there is a event OnStyleNeeded. This is exactly what I'm looking for.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This event occurs every time when some action needs a style with certain properties. This even may occurs when applying some change to the selection, or when inserting hyperlink.
If this event is not processed, the default procedure provides this style (creates a new style or returns the existing style with these properties).

This event rarely needs to be used (for example it can be used to prevent reusing of some styles, or to disallow some formatting)
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

Post by BernhardRoos »

But seems the only way to set the font in controls. So far I've tested I can't see any problems with it.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

For example, if the user selects large document fragment and applies font, this event occurs for each item in the selection. Which one you will use for TEdits?

It's possible to apply fonts to inserted controls, but it requires creating a special item type for them.
Post Reply