CTRL+I - what's it doing?

General TRichView support forum. Please post your questions here
Post Reply
AndyBell
Posts: 30
Joined: Thu Jul 29, 2010 11:38 am
Location: Surrey, UK

CTRL+I - what's it doing?

Post by AndyBell »

In a very basic TRichEdit C++ Builder 11.1 app, without using RichViewActions, CTRL+I seems to be inserting a tab and Shift+CTRL+I seems to insert a space.

It's very annoying and I have a bigger app where, for reasons I've not yet fathomed, the Shortcut Keys in the Actions don't fire, so I'm having to detect them in the form and then trigger the appropriate Action. But TRichEdit still carries out the CTRL+I action - inserting a tab and messing up my text.

Simple question - Can I stop TRichEdit responding to CTRL+I when no actions are wired in?

Andy
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: CTRL+I - what's it doing?

Post by standay »

It's doing a built-in tab insert. The way I override ctrl + i is to assign a popup menu with an item that has a ctrl + i shortcut assigned to it. Sergey might have another way but that's the only one I know.
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: CTRL+I - what's it doing?

Post by Sergey Tkachenko »

TRichViewEdit itself does not handle Ctrl+I.
Ctrl+I inserting a tab character is a Windows feature. You can see it even in Notepad.
So the only way to avoid it is processing this shortcut yourself. Do you have some control or menu item linked with Italic (Ctrl+I) on the editor's form?
AndyBell
Posts: 30
Joined: Thu Jul 29, 2010 11:38 am
Location: Surrey, UK

Re: CTRL+I - what's it doing?

Post by AndyBell »

Hi standay and Sergey

My form has an ActionList with the Richview actions in it and also a toolbar with a button linked to the Italic action (and ones for bold, underline etc).

The problem is, and I still haven't figured why, the hotkeys on the actions are not working - CTRL + I goes straight to the RichEdit and causes the behaviour I've described. As my app is a bit complex graphically, and uses an LMD control to host forms inside of other forms, I'm guessing the keyboard events are not being properly handled somewhere. A simple, standalone form does not have the problem.

In any case, standay's suggestion of having a popup menu with the same hotkeys works - I just assigned the right Action to each item in the menu and everything works ok. As I was going to have a popup menu for the Richedits in the app, this is a solution that doesn't compromise the look and feel or functionality of my app.

It still doesn't explain why the hotkeys on the toolbar don't respond, but I've seen this behaviour in C++ Builder apps going back to V5... Not sure if it happens in Delphi - I sometimes think that C++ Builder events aren't as robust as they could be, even in V11.1 Alexandria.

Thanks for your help

Andy
skamradt
Posts: 7
Joined: Mon Jul 28, 2008 9:18 pm

Re: CTRL+I - what's it doing?

Post by skamradt »

I recently discovered this problem as well after recently moving my code to Delphi 11.3 from 10.2. What I ended up doing was capturing the key and dispatching to the action in the onkeydown event, and also the keypress event for ^I on the edit as it was echoing a tab as well.

Code: Select all

procedure TEditorActionsModule.OnEditKeyPress(Sender: TObject;
  var Key: Char);
begin
  if (key = ^I)  and (HiWord(GetKeyState(vkControl)) <> 0) then
    key := #0;
end;
I placed this action in a global datamodule with all of my other actions as I have multiple edits throughout my application that use the same set of actions.
Post Reply