Solved

D1 Button Activation By Space Bar

Posted on 1999-01-18
7
156 Views
Last Modified: 2010-04-06
Using Delphi 1. If the user presses the space bar, any highlighted button is activated. How do I stop this happening, so that the button is only activated when the user hits CR or clicks on the button with the mouse?
0
Comment
Question by:itoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 

Author Comment

by:itoft
ID: 1362369
Edited text of question
0
 

Author Comment

by:itoft
ID: 1362370
Edited text of question
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 150 total points
ID: 1362371
This is the default windows behaviour (ie: space = mouse click on active control).

You could stop it by setting form1.keypreview to true and setting an on KeyDown event for the form. Check if it is a space and that the active control is a button and nix the char if so:

       procedure TForm3.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (key = vk_space) and (activecontrol is TButton) then // swallow it...
    key := #0;
end;

Cheers,

Raymond.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:rwilson032697
ID: 1362372
Oops, that should read:

key := 0;

Cheers,

Raymond.
0
 

Author Comment

by:itoft
ID: 1362373
Unfortunately my question was not detailed enough as my question has been answered, but it doesn't solve my problem.
I wish to disable the space=mouse click on active control when a MessageDlg object is displayed, while still being able to detect which button on the MessageDlg foorm has been pressed.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1362374
This is a bit trickier. What you will need to do is implement your own messagedlg form which looks and feels the same but catches the space key as you require.

Cheer,

Raymond.
0
 

Author Comment

by:itoft
ID: 1362375
Adjusted points to 150
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question