This is a migrated thread and some comments may be shown as answers.

RadRichTextBox Magnification key?

2 Answers 158 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Joan VANDERWEYST
Top achievements
Rank 1
Joan VANDERWEYST asked on 19 Nov 2014, 04:12 PM
I know that you can hold down the CONTROL key and use the mouse wheel to change the magnification in the RadRichTextBox.

Is there a way to do the same thing without using the mouse wheel?  Can I change the magnification using the keyboard only?

Also, we do not want to use a separate slider control to change magnification.  Just a simple key combination would be nice.

2 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 21 Nov 2014, 01:20 PM
Hello Joan,

As there isn't an existing command which is responsible for the zoom in/out of a document, you hook up on the RadRichTextBox's KeyUp event and execute the desired logic there. 

For example, you can use the following code snippet which does what you've described:
double scalingStep = 0.1;
this.radRichTextBox.KeyUp += (s,e) =>
    {
        if(!((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control))
        {
            return;
        }
 
        double newWidth = this.radRichTextBox.ScaleFactor.Width;
        double newHeight = this.radRichTextBox.ScaleFactor.Height;
        if (e.Key == Key.Up)
        {
            newHeight += scalingStep;
            newWidth += scalingStep;
        }
        else if (e.Key == Key.Down)
        {
            newHeight -= scalingStep;
            newWidth -= scalingStep;
        }
 
        this.radRichTextBox.ScaleFactor = new Size(Math.Max(0,newWidth), Math.Max(0, newHeight));
    };

In the example above CTRL + UpArrow Key zooms in, and the CTRL + DownArrow Key combination zooms out.

I hope this helps.


Regards,
Todor
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Joan VANDERWEYST
Top achievements
Rank 1
answered on 02 Dec 2014, 09:19 PM
Thanks! That worked perfectly!
Tags
RichTextBox
Asked by
Joan VANDERWEYST
Top achievements
Rank 1
Answers by
Todor
Telerik team
Joan VANDERWEYST
Top achievements
Rank 1
Share this question
or