VintaSoft PDF .NET Plug-in Discussions

Questions, comments and suggestions concerning VintaSoft PDF .NET Plug-in.

Board index < VintaSoft Imaging < VintaSoft PDF .NET Plug-in Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

PdfFreeTextAnnotation Edit Mode Capturing Keyboard Events



PdfFreeTextAnnotation Edit Mode Capturing Keyboard Events

Post by IntegraMike »

Hello, we're working on doing some custom hotkey work for the PdfFreeTextAnnotations, specifically when they're in text edit mode but having some issues trapping/overriding the default hotkeys. We're specifically looking at CTRL+I and CTRL+B right now but are not seeing where the events are for the editor that handle keyboard input. If you could point us in the right direction we would appreciate it.

Thanks!
Mike


Re: PdfFreeTextAnnotation Edit Mode Capturing Keyboard Events

Post by Alex »

Hello Mike,

Do you use WinForms or WPF?

Best regards, Alexander


Re: PdfFreeTextAnnotation Edit Mode Capturing Keyboard Events

Post by IntegraHarlan »

Hi Alexander,
We are using WinForms

Thanks


Re: PdfFreeTextAnnotation Edit Mode Capturing Keyboard Events

Post by Alex »

Hi Harlan,

Thank you for information.

For solving your task you need to create manager, which stores and manages settings for interaction areas of visual tool, implement necessary logic in manager and specify that manager must work with PDF annotation tool:
/// <summary>
/// Stores and manages settings for interaction areas of visual tool.
/// </summary>
public class TextBoxInteractionAreaAppearanceManager : InteractionAreaAppearanceManager
{

    /// <summary>
    /// Initializes a new instance of the <see cref="TextBoxInteractionAreaAppearanceManager"/> class.
    /// </summary>
    public TextBoxInteractionAreaAppearanceManager()
    {
    }



    /// <summary>
    /// Sets the text box settings.
    /// </summary>
    /// <param name="textBox">The text box of interactive object (PdfFreeTextAnnotation, etc).</param>
    public override void SetTextBoxSettings(RichTextBox textBox)
    {
        base.SetTextBoxSettings(textBox);

        if (textBox != null)
        {
            // subscribe to the KeyDown event of text box
            textBox.KeyDown += TextBox_KeyDown;
        }
    }

    /// <summary>
    /// Key is pressed in text box.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
    private void TextBox_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Modifiers == Keys.Control)
        {
            switch (e.KeyCode)
            {
                case Keys.I:
                    MessageBox.Show("CTRL+I is pressed");
                    break;

                case Keys.B:
                    MessageBox.Show("CTRL+B is pressed");
                    break;

                case Keys.L:
                    // show text
                    MessageBox.Show(((TextBoxBase)sender).Text);
                    break;
            }
        }
    }

}



// ...
// create manager that stores and manages settings for interaction areas of visual tool
TextBoxInteractionAreaAppearanceManager textBoxInteractionAreaAppearanceManager = new TextBoxInteractionAreaAppearanceManager();
// specify that manager must work with annotation visual tool
textBoxInteractionAreaAppearanceManager.VisualTool = _annotationTool;
// ...
Best regards, Alexander


Page 1 from 1: 1