Keyboard events

Dear All,

In the main form of the application I'm working with, I have a TFrame
with the following layout of components:

MyFrame
    OKBtn (mbOK)
    CancelBtn (mbCancel)
    PageControl1
        TabSheet1
            Memo1
        TabSheet2
            StringGrid1

StringGrid1.Options do not normally include goRowSelect and
goRangeSelect to enable the user to edit the cells.

To enable the user to copy and paste I include goRowSelect and
goRangeSelect in a OnKeyDown event (of the  StringGrid) if ssShift is
in Shift and the key is VK_DOWN or VK_UP. (And in a similar way for
the mouse in a MouseMove handler) This works OK.

The user should be able to cancel the selection with the Esc key when
there is a selection in the grid or Escape the frame if there's not a
selection in the grid.

Currently pressing Esc always closes (cancels) the frame. This is OK
except for when there is a selection in the grid.

How do I setup keyboard event handlers to catch the Esc key when
there's a selection in the grid?

Thanks for any suggestions
Tom
0
Tom
8/12/2008 1:30:18 PM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

5 Replies
1779 Views

Similar Articles

[PageSpeed] 10
Get it on Google Play
Get it on Apple App Store

Tom Brunberg wrote:

> Dear All,
> 
> In the main form of the application I'm working with, I have a TFrame
> with the following layout of components:
> 
> MyFrame
>     OKBtn (mbOK)
>     CancelBtn (mbCancel)
>     PageControl1
>         TabSheet1
>             Memo1
>         TabSheet2
>             StringGrid1
> 
> StringGrid1.Options do not normally include goRowSelect and
> goRangeSelect to enable the user to edit the cells.
> 
> To enable the user to copy and paste I include goRowSelect and
> goRangeSelect in a OnKeyDown event (of the  StringGrid) if ssShift is
> in Shift and the key is VK_DOWN or VK_UP. (And in a similar way for
> the mouse in a MouseMove handler) This works OK.
> 
> The user should be able to cancel the selection with the Esc key when
> there is a selection in the grid or Escape the frame if there's not a
> selection in the grid.
> 
> Currently pressing Esc always closes (cancels) the frame. This is OK
> except for when there is a selection in the grid.
> 
> How do I setup keyboard event handlers to catch the Esc key when
> there's a selection in the grid?
> 
> Thanks for any suggestions
> Tom

You may be interested in this CodeCentral entry:
http://cc.codegear.com/Item/25888

What you need here is a handler for the CM_DIALOGKEY message on the
frame itself. If you call the inherited handler it would fire the
cancel button. You can first check the grids state and react to
VK_ESCAPE in the appropriate manner, then set message.result to 1 to
mark the key as handled.

-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
0
Peter
8/12/2008 7:14:52 PM
"Peter Below" <none@nomail.please> kirjoitti 
viestissä:1678@forums.codegear.com...

> You may be interested in this CodeCentral entry:
> http://cc.codegear.com/Item/25888

Peter,

I just downloaded the article and after briefly skimming through it, 
I'm convinced that all my current and future questions about keyboard 
handling are answered. Marvelous piece of document. And you published 
it only a few hours before I started to wonder how to solve this 
issue, Just On Time ;-)

Thank you

Best regards
Tom
0
Tom
8/12/2008 7:45:29 PM
Tom Brunberg wrote:

> Marvelous piece of document.

I agree. It should be part of the Delphi documentation <g>

-- 
Dave Nottage [TeamB]
0
Dave
8/13/2008 12:27:08 AM
Peter Below wrote:

> Tom Brunberg wrote:
> 
> > Dear All,
> > 
> > In the main form of the application I'm working with, I have a
> > TFrame with the following layout of components:
> > 
> > MyFrame
> >     OKBtn (mbOK)
> >     CancelBtn (mbCancel)
> >     PageControl1
> >         TabSheet1
> >             Memo1
> >         TabSheet2
> >             StringGrid1
> > 
> > StringGrid1.Options do not normally include goRowSelect and
> > goRangeSelect to enable the user to edit the cells.
> > 
> > To enable the user to copy and paste I include goRowSelect and
> > goRangeSelect in a OnKeyDown event (of the  StringGrid) if ssShift
> > is in Shift and the key is VK_DOWN or VK_UP. (And in a similar way
> > for the mouse in a MouseMove handler) This works OK.
> > 
> > The user should be able to cancel the selection with the Esc key
> > when there is a selection in the grid or Escape the frame if
> > there's not a selection in the grid.
> > 
> > Currently pressing Esc always closes (cancels) the frame. This is OK
> > except for when there is a selection in the grid.
> > 
> > How do I setup keyboard event handlers to catch the Esc key when
> > there's a selection in the grid?
> > 
> > Thanks for any suggestions
> > Tom
> 
> You may be interested in this CodeCentral entry:
> http://cc.codegear.com/Item/25888
> 
> What you need here is a handler for the CM_DIALOGKEY message on the
> frame itself. If you call the inherited handler it would fire the
> cancel button. You can first check the grids state and react to
> VK_ESCAPE in the appropriate manner, then set message.result to 1 to
> mark the key as handled.

Wow! Incredible resource. Really masterfully done, Peter. I just
downloaded and read some of the doc file. Can't wait to go over it all
carefully. As I've said before, you really should consider putting out
a book -- or a series of them. This prooves you could do a fantastic
job of it.

--
0
Joe
8/13/2008 11:05:05 AM
Joe Hicks wrote:

> > You may be interested in this CodeCentral entry:
> > http://cc.codegear.com/Item/25888
> 
> Wow! Incredible resource. Really masterfully done, Peter. I just
> downloaded and read some of the doc file. Can't wait to go over it all
> carefully. As I've said before, you really should consider putting out
> a book -- or a series of them. This prooves you could do a fantastic
> job of it.

Thanks for the flowers <g>. Unfortunately writing books is not an
option. If I ever had to earn my living by writing I would starve, 	I'm
way too slow at this...



-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
0
Peter
8/13/2008 5:31:50 PM
Reply:

Similar Artilces:

C++ Events like Delphi events
Hello everyone, This is not exactly a doubt about Delphi programming, it is more related to C++ programming, but, as I´m used to Delphi programming, I´m a little confused with some aspects of C++ Programming.. The problem that I have is with object events on C++, for example, I have the simple classes: TMyObject = class private FEvent: TNotifyEvent; procedure TriggerEvent; public OnEvent: TNotifyEvent read FOnEvent write FOnEvent; end; OK, This is a simple class that I want to use on several different places in my program, inside several differ...

web application wide event handling-keyboard events
hello, How would I capture a KeyDown event in all the Pages in my Web Application using VB code?  Are there any examples of how to do this please? The goal is to capture the key code and then build a case statement based on what key was pressed. I need to call the socket class in VB .NET  in the case statement, so I have to write the case statement in VB, so I could use the VB socket code.  Just so nobody gets confused, this question was answered here: http://forums.asp.net/966964/ShowPost.aspx...

KeyBoard Events
I've a problem with my asp application because I don´t Know how to capture KeyBoard Events and I would like to capture the 'Enter' Key Event. The problem is that the application works perfectly except when the user press 'Enter'; when it occurs, I don´t know which part of the code is executed. I supose that it's something related with the Focus of the page, because in some pages it executes the event of a button, but I can't keep control on what's happening. Could anybody help me Thanks your probably setting the button to post back to the server and in the "oncli...

web application wide event handling-keyboard events #2
hello, How would I capture a KeyDown event in all the Pages in my Web Application using VB code?  Are there any examples of how to do this please?I am interested in doing things like you can do using Control.KeyDown Event, but globally for all pages.Could I put key event handling code into a User Control (ascx file) in the Page_Load evenet, then include this control in all my .aspx file?If yes, what would I need to use to capture the key event here? Do I need to Import anything at the top?  There is no keydown server side event.  If you wanted to capture all k...

What generals generally do
Reading a McChrystal thread elsewhere, I came across someone quoting a US general http://en.wikipedia.org/wiki/Smedley_Butler > I spent 33 years and four months in active military service and > during that period I spent most of my time as a high class thug for > Big Business, for Wall Street and the bankers. In short, I was a > racketeer, a gangster for capitalism. I helped make Mexico and > especially Tampico safe for American oil interests in 1914. I helped > make Haiti and Cuba a decent place for the National City Bank boys to > collect revenues in. I ...

delphi.general
Sorry if this is "out of topic"! but since some days ago I can't read the group *embarcadero.public.delphi.language.delphi.general* Does anybody know if there's something wrong with it? Or maybe is my reader? (Thunderbird) I get this messagge when I try to read the latest messages: Error! newsgroup server responded:no such article found Perhaps the article has expired <692702@forums.embarcadero.com> (33145) Click here to remove all expired articles sergio wrote: > Sorry if this is "out of topic"! but since some days ago I can'...

superreview requested: [Bug 319554] Keyboard modifier (shift, ctrl, alt) and left-clicking on a link creates an event that is NOT cancelable by event handler : [Attachment 229281] xpfe fix
neil@parkwaycc.co.uk <neil@httl.net> has asked jag (Peter Annema) <jag@tty.nl> for superreview: Bug 319554: Keyboard modifier (shift,ctrl,alt) and left-clicking on a link creates an event that is NOT cancelable by event handler https://bugzilla.mozilla.org/show_bug.cgi?id=319554 Attachment 229281: xpfe fix https://bugzilla.mozilla.org/attachment.cgi?id=229281&action=edit ...

superreview granted: [Bug 319554] Keyboard modifier (shift, ctrl, alt) and left-clicking on a link creates an event that is NOT cancelable by event handler : [Attachment 229281] xpfe fix
jag (Peter Annema) <jag@tty.nl> has granted neil@parkwaycc.co.uk <neil@httl.net>'s request for superreview: Bug 319554: Keyboard modifier (shift,ctrl,alt) and left-clicking on a link creates an event that is NOT cancelable by event handler https://bugzilla.mozilla.org/show_bug.cgi?id=319554 Attachment 229281: xpfe fix https://bugzilla.mozilla.org/attachment.cgi?id=229281&action=edit ...

superreview requested: [Bug 313443] Caret move events from keyboard input not reported for XUL textboxes : [Attachment 228979] Ensure correct selection attached for each focus event, comments in patch
Aaron Leventhal <aaronleventhal@moonset.net> has asked neil@parkwaycc.co.uk <neil@httl.net> for superreview: Bug 313443: Caret move events from keyboard input not reported for XUL textboxes https://bugzilla.mozilla.org/show_bug.cgi?id=313443 Attachment 228979: Ensure correct selection attached for each focus event, comments in patch https://bugzilla.mozilla.org/attachment.cgi?id=228979&action=edit ...

superreview cancelled: [Bug 313443] Caret move events from keyboard input not reported for XUL textboxes : [Attachment 228979] Ensure correct selection attached for each focus event, comments in patch
Aaron Leventhal <aaronleventhal@moonset.net> has cancelled Aaron Leventhal <aaronleventhal@moonset.net>'s request for superreview: Bug 313443: Caret move events from keyboard input not reported for XUL textboxes https://bugzilla.mozilla.org/show_bug.cgi?id=313443 Attachment 228979: Ensure correct selection attached for each focus event, comments in patch https://bugzilla.mozilla.org/attachment.cgi?id=228979&action=edit ...

superreview requested: [Bug 313443] Caret move events from keyboard input not reported for XUL textboxes : [Attachment 228999] Also shows MSAA caret move events for hidden caret
Aaron Leventhal <aaronleventhal@moonset.net> has asked neil@parkwaycc.co.uk <neil@httl.net> for superreview: Bug 313443: Caret move events from keyboard input not reported for XUL textboxes https://bugzilla.mozilla.org/show_bug.cgi?id=313443 Attachment 228999: Also shows MSAA caret move events for hidden caret https://bugzilla.mozilla.org/attachment.cgi?id=228999&action=edit ...

superreview granted: [Bug 313443] Caret move events from keyboard input not reported for XUL textboxes : [Attachment 228999] Also shows MSAA caret move events for hidden caret
neil@parkwaycc.co.uk <neil@httl.net> has granted Aaron Leventhal <aaronleventhal@moonset.net>'s request for superreview: Bug 313443: Caret move events from keyboard input not reported for XUL textboxes https://bugzilla.mozilla.org/show_bug.cgi?id=313443 Attachment 228999: Also shows MSAA caret move events for hidden caret https://bugzilla.mozilla.org/attachment.cgi?id=228999&action=edit ...

superreview requested: [Bug 290355] Focus events wrong in manage bookmarks and tree views in general : [Attachment 183422] 1) Simulate a focus event in our own code when a new window accessible is cr
Aaron Leventhal <aaronleventhal@moonset.net> has asked neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> for superreview: Bug 290355: Focus events wrong in manage bookmarks and tree views in general https://bugzilla.mozilla.org/show_bug.cgi?id=290355 Attachment 183422: 1) Simulate a focus event in our own code when a new window accessible is created, so that initial MSAA focus event gets fired, 2) Only fire MSAA focus for tree items when owning tree view is focused https://bugzilla.mozilla.org/attachment.cgi?id=183422&action=edit ------- Additional Comments...

superreview granted: [Bug 290355] Focus events wrong in manage bookmarks and tree views in general : [Attachment 183422] 1) Simulate a focus event in our own code when a new window accessible is crea
neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> has granted Aaron Leventhal <aaronleventhal@moonset.net>'s request for superreview: Bug 290355: Focus events wrong in manage bookmarks and tree views in general https://bugzilla.mozilla.org/show_bug.cgi?id=290355 Attachment 183422: 1) Simulate a focus event in our own code when a new window accessible is created, so that initial MSAA focus event gets fired, 2) Only fire MSAA focus for tree items when owning tree view is focused https://bugzilla.mozilla.org/attachment.cgi?id=183422&action=edit ...

Web resources about - Keyboard events - embarcadero.delphi.general

Pro Tools Keyboard Shortcuts
Every shortcut you ever wanted. ∞ Read this on The Loop

Keyboard technology - Wikipedia, the free encyclopedia
There are two types of membrane-based keyboards, flat-panel membrane keyboards and full-travel membrane keyboards: Flat-panel membrane keyboards ...

Facebook Adds Keyboard Shortcuts To Messages Inbox
Facebook added a list of keyboard shortcuts to the inbox where users retrieve their messages . continued… New Career Opportunities Daily: The ...

Facebook rolls out messages update with new layout, photo sharing, emoticons, keyboard shortcuts and ...
... continues to roll out its redesigned messages product it announced in August , including a two-paned layout, improved photo uploads and keyboard ...

Jakarta attacks: Terrorist Bahrun Naim's keyboard campaign for Islamic State
Police in Jakarta accuse a firebrand Indonesian fighting in Syria with Islamic State of inspiring Thursday's terrorist rampage.

Apple's latest magic keyboard and mouse make typing fun again
The Magic Keyboard and Magic Mouse 2 are great accessories made even better.

Gallery: With tvOS 9.2, Apple TV adds Podcasts app, Folders, Bluetooth keyboard support, new app switcher ...
... Apple TV tvOS 9.2 beta, Apple has added a whole host of new features to the tvOS platform. This includes support for pairing Bluetooth keyboards, ...

Type faster in Hindi with Google's Indic Keyboard
... typing easier for the almost 1 billion people around the world who speak a number of Indian languages, Google has built a dedicated Indic Keyboard. In ...

Microsoft’s Word Flow keyboard on Windows Phone is coming to iOS
... operating system to Apples. As reported by WinBeta , Microsoft is working on extending the availability of its Word Flow smartphone keyboard ...

tvOS 9.2 beta 1 adds support for app folders, Bluetooth keyboards
... of new capabilities for the fresh platform, including the ability to stow apps in folders on the home screen, and to connect a Bluetooth keyboard ...

Resources last updated: 1/20/2016 4:59:03 PM