Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conflict in shortcut and typing 2

Status
Not open for further replies.

pierrotsc

Programmer
Nov 25, 2007
358
US
I have a few buttons that have an action associated with them. These actions have a shortcut. So when i press I, i have the eyedropper button that becomes depressed. Everything is good.
Now i have a TDBgrid and when i try to modify the text in one cell, I cannot press I. The button will become depressed but no letter can be typed.

Can that be resolved?
Thanks.
P
 
I think what may be happening is that when the button is depressed, your application's focus is moved from what ever control it was on, to the button that was depressed.

What type of button are you using? A TButton and TBitBtn can receive/steal input focus, deselecting the currently selected component when it is pressed.

Either use a TSpeedButton, or create a Tcoolbar, with a Ttoolbar and Ttoolbuttons on them. These controls cannot be "focused" the way the other button types can.
 
What kind of button are you using? This almost sounds like a "function button", like what is on the toolbar when you use Microsoft Paint. It permanently depresses for whatever function you want and won't allow others unless you select them first.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
I am using almdev businesssking component. I have a toolbar with some speedbutton inside. (from the almdev components).

Could i set the focus to the grid when i click on the cell and release the focus back to the form when i validate my entry?
P
 
Not knowing about these components, I just can't tell if the components themselves are the basis of the problem. You may want to go directly to them for support.
 
Yep, I did. I send them an email but i think these components act just like the delphi standard ones. The only difference is that you can skin them. I am going to try the solution you provided above to see if that works.
Thanks for replying.
P
 
Ok, i tried with normal delphi components.
I tried the tspeedbutton suggestion and the Tcoolbar, ttoolbar and ttoolbutton suggestion. Same behavior. As soon as i pressed I, the icon get depressed and I cannot type the letter i in the tdbgrid description.
I still use the action shortcut.
I am puzzled.
P
 
Have you got any keyboard events defined globally for the application? For example, I can set KeyPreview to True, do something like below and duplicate what you indicate is happening.

Code:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = 'I' then
    ShowMessage('You Pressed I');
  Key := #0;
end;

The message shows up if I type "I" in any other control of the form, but won't allow I in the controls of the other form (TEdit).

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Thanks for the tip. I do have the keypreview set to true but in my formkeypress i only handle the [ and ].
All the shortcuts are in actions. I really like actions.
I tried to set the keypreview to false the the action shortcut is still triggered.
I found a solution. When i click on the cell, i disable the action. When i validate the cell, i re enable the action. It looks like it is working.
Thanks for the brainstorming guys. If someone else finds a more elegant way, just let me know.
P
 
Ok...one more question. Instead of disabling the action, i would like just to disable/enable the action shortcut. How can i do that? My action shortcut is I.

Thanks.
P
 
You can clear a shortcut with

ActionName.ShortCut := TextToShortCut(');

and re-establish it with

ActionName.ShortCut := TextToShortCut('Alt+I')
 
the quote got "eaten"

Code:
ActionName.ShortCut := TextToShortCut(');
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top