How to change key mapping in Delphi 10.1 Berlin? - delphi

I want to change some shortcuts for speed settings in my processes. I know that there is an option to change it from Tools > Editor Options > Key Mappings menu but I want to re-assign some keys manually.
Is it possible to assign them from Delphi IDE directly without using any third party?

Just putting #Rudy Velthuis' comment as a answer:
Yes, you can remap keys, but only using a custom (partial) keybinding package, which you can easily write and install yourself. An example can be found on GitHub. You cannot, however, directly change key mappings "on the fly", unless you use a third party tool.

Related

delphi integrate custom file editor into IDE

I have deveoped a custom file type, together with a custom editor (basically a tree with several data pages attached and a few extra buttons). OK, I can run it stand alone and that is fine, and even add it to the tools menu, but I would like to integrate it into the Delphi IDE so that my custom editor (or a similar new version) appears in the IDE, rather like a DFM file has a custom editor. I can find references to most extensions in the Delphi IDE, but not this one. Any guiding hands? Note that this is not a property or component editor (the file type has nothing to do with either of these) nor is it simply syntax highlighting of a text file.
AFAIK it currently isn't possible to reliably integrate a custom editor into the Delphi IDE. The required API simply isn't there. See QC89028 Custom Module support.
During the Delphi 2010 and XE betas I spent most my spare time trying to get a resource editor integrated. Although the effort had the official blessing of Embarcadero and got some, half hearted, support from the IDE engineer, I was never able to get them to deliver on their promises and surface the module API. I eventually abandoned the project.
Update: I've now checked my old correspondence regarding this and it turns out part of the problem was that IOTAModuleCreator (used to implement File|New for custom file types) and IOTAEditorContent (used to transfer data to/from the custom module) only supports text data. Binary data gets mangled.
You can probably do this via an IDE plugin that uses the ToolsAPI (see ToolsAPI.pas in the IDE's source folder (e.g. Program Files (x86)\Embarcadero\Studio\source\ToolsAPI\ToolsAPI.pas.)
For information on writing a plugin in general, see David G Hoyle's excellent blog. Once you know the basics - i.e., write a 'wizard' and get it to do something - you will need to work on integrating your editor.
I have never done this, and so I can't guarantee it is possible. However, some interfaces that look worth investigating and implementing are INTACustomEditorView, which represents a 'view' (file tab when that file is open - think the code editor, Welcome view, type library editor, etc) and IOTAEditorViewServices, to register your custom view. I do not know how you associate a view type with a file type, sorry - possibly something to do with the personality interfaces. You might also be interested in INTACustomEditorSubView which is what creates a tab on the bottom of a file.
Good luck, and if you find a solution please write here so that other people can learn too!

Move selected text to right/left

How to move selected source text to left or right in Delphi 2007 code editor? I need short key command. Is it possible at all in Delphi 2007? How about other versions? Is it possible to manage this with any additional tools?
You can indent/outdent (unindent) selected text in the Code Editor with the default keymapping using Ctrl+Shift+I (Indent) and Ctrl+Shift+U (Unindent).
(Recent versions of the IDE use Tab and Shift+Tab to do this as well.)
If you're using another key mapping (such as Brief or Visual Studio), you can find a list of the key mappings in the help file under Key Mappings; the individual key assignments are listed there.

Code templates - unit name clash between Delphi versions

Different Delphi versions (in my case 2007, XE and XE2) seem to use the same code-template repository, such as ..\Documents\RAD Studio\code_templates. Since XE2 uses namespaced units, this causes problems when one have to use a unit name in a template.
For instance I have a template when I write winbeep which completes to windows.Beep(300, 100); and selects and stops on frequency etc.. This does not compile on XE2 unless I remove the Winapi. part of the Windows unit in the uses clause (or of course add the prefix manually). I have to have the unit name because otherwise SysUtils.Beep gets referred.
I couldn't find an option entry or a registry key or an environment variable specifying the place of the templates. It is not even related to BDSUSERDIR, in fact I don't even have a directory in my computer having the path of BDSUSERDIR (which is ..\Documents\RAD Studio\9.0). Is this my oversight and in fact there's an option to relocate code templates? If not, is it possible to make the IDE use unit aliases in uses clause for new forms?
edit:
Here it is stated that (emphasis by me) "Templates that you create (and templates provided by third party add-ins) are saved by default in the \My Documents\RAD Studio\code templates\ directory." That would imply there should be way to save them in a non-default place. But the article does not mention how.
You can put your templates in "Delphi installation folder"\ObjRepos\en\Code_Templates to make them visible only on one Delphi version.
Edit
As Sertac points out in the comments, Template libraries are related to project templates, not code templates. Leaving this answer in place because it may help people looking for ways to structure / share / split their project template repositories.
In Delphi XE2 you have a "Template libraries" option under the "Tools" menu. When you open that, you get this dialog:
The "Add" button allows you to add a folder, the "Properties" button allows you to view and manage the contents of that repository.
So it would seem to me that you can simply copy the template library, change it XE2 specific stuff, and then point XE2 to its own repository. Or you could do that only for the templates that require specific XE2 unit handling.

Updates for controls in Win3.1 palette

Some people are saying that I must update the controls in Win3.1 palette (especially TFilterComboBox) with modern ones. But does Delphi provide such new controls?
I need to create a GUI (somehow similar to Windows Explorer, consisting in a DirectoryListBox, FileListBox and a FilterComboBox) where I allow the user to easily explore for files of a specific type. Since the interface is centered around this Explorer, a TOpenDialog will be like hitting the customer with a hammer in the middle of his head. I need an 'easy to use' solution.
Unfortunately Shell Controls are not stable enough to be used as replacement.
The Shell Controls that come as a demo with Delphi only have to be installed, and you'll have some nice shell controls. There is, IMO, no big need to get 3rd party components for that.
Look for ShellCtls (or similar, can't check right now) in your demos folder. That Demos folder can be accessed from the Windows Start menu for your version of Delphi.
Update
They are not in a Demos folder, it is called Samples now. They can be found in Samples\Delphi\VCL\ShellControls. Install vclshlctrls.dproj first and then dclshlctrls.dproj.
In our application we use tpShellShock which works rather well. You may need to tweak it a little for Unicode Delphi, but if I recall correctly that was pretty simple to do.
Here's what it looks like:

Delphi 2006 refactoring keyboard mappings

How do I change the default refactoring keyboard mappings in Delphi 2006?
As you probably know, in D2006 you can find the settings under:
Tools > Options > Editor Options > Key Mappings
Also, there is the "Editor speedsetting" under:
Tools > Options > Editor Options
However, these don't give you direct control over the keymappings, they just let you choose a keymapping from among the installed Enhancement Modules. Per D2006 Help:
Enhancement modules
Enhancement modules are special packages that are installed and
registered and use the keyboard
binding features that can be developed
using the Open Tools API. You can
create enhancement modules that
contain new keystrokes or apply new
operations to existing keystrokes.
Once installed, the enhancement modules are displayed in the
Enhancement modules list box. Clicking
the check box next to the enhancement
module enables it and unchecking it
disables it. Key mapping defined in an
installed and enabled enhancement
module overrides any existing key
mapping defined for that key in the
key mapping module which is currently
in effect.
Clearly, this is not a quick do-it-yourself setting.
GExperts has a feature supporting IDE Menu Shortcuts that support hotkey configuration of any IDE menu command, including refactoring commands.

Resources