Dienstag, 27. März 2007

Tips and Tricks: Quickly change between editor tabs

When you've got many files open in the code editor of Delphi, there's another handy but undocumented shortcut: pressing Ctrl+Alt+F12 opens the drop-down on the top-right corner of the editor, listing all open files.

Use incremental search (i.e. just start typing) to select the file you want and then press Enter to activate that editor tab!

That's just one of the many editor shortcuts. Check out the Delphi Wiki for more.

Sonntag, 25. März 2007

Tips and Tricks: quickly changing property values

Here's another handy series of shortcuts for Delphi: when designing forms it is very cumbersome to switch between the Form Designer and Object Inspector, since you would have to hit the F12 key twice to return from OI to the form.

But there's a better way: just start typing while the form is active. Delphi will automatically switch to OI and change the currently active property. When you're done, press Enter to return to the Form Designer! Very handy to quickly change a series of TLabel captions for example.
And if you don't want to change the currently active property, but another one: start by pressing Enter. This activates OI and you can then use the shortcuts I described here to navigate to a different property or event.

Note that this trick is not only limited to the Form Designer. It also works with the various Property Editors, such as the Collection Editor or the Fields Editor! To make this work with your own Property Editors, descend from TDesignWindow and in the appropriate KeyPress event call TDesignWindow.ActivateInspector passing the pressed key as a parameter.

Tips and Tricks: Keyboard navigation in Delphis Object Inspector

I'm a keyboard person and I absolutely hate having to switch to the mouse while I'm in the middle of a coding session. Because of that I'm always on the lookout for keyboard shortcuts.

This time I want to share some tricks on how you can navigate Delphis Object Inspector!
Note: most if not all of these shortcuts have been supported since Delphi 1, so while I'm referring to the brand new Delphi 2007 now, everything should apply to older Delphi versions too!

While the Object Inspector is active, you can switch between the 2 columns of the inspector, using the Tab key. This is very handy, because you can use incremental search to navigate to a property! Just start typing while the cursor is in the name column, i.e. after pressing Tab.
While the name column is active you can also use "." (dot), to expand a subproperty! Similarily, use Backspace to collapse a subproperty.

Now back to the value column: when editing a property where you can only choose from a list of distinct values (i.e. a combobox), for example TForm.Align, use Alt+Down to drop down the list of values. Use the cursor keys to select a different item, Enter to confirm the selection and Esc to cancel the operation.

For properties supporting a property editor, such as TForm.Font, press Ctrl+Enter to invoke that editor - in the case of .Font that opens the Font common dialog.

Then there's also the instance list above Object Inspector - use Ctrl+Down to activate that! Note that this drop down also supports incremental search, so you can just start typing. Again, use Enter to select the highlighted component in Object Inspector.

Finally there's also the Events page. Note that you can switch between those 2 pages by pressing Ctrl+Tab! On the events page, use Ctrl+Enter to create a new event handler or switch to the code of the already assigned event handler.

That's about all the OI related shortcuts I know. If I missed one, please leave a note and I'll update the post!

First Post

Hey, this is my first blog post! I'm a bit late to the blogger party, but better late than never.
I'm a 31 year old self-employed programmer living in Berlin, Germany and a long-time Delphi enthusiast - since Version 1 came out in 1995! Most of my work is related to measurement and automation, collaborating with puhlmann electronics.
I'm also a big supporter of QualityCentral, CodeGear's bug reporting database.