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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vk_shift and vk_tab 1

Status
Not open for further replies.

pierrotsc

Programmer
Nov 25, 2007
358
US
Ok, i know on how to program the capture of vk_shift and vk_tab but I would like to capture the Shift+Tab combination. How do i do that?
Thanks.
PO
 
I assume this is out of a KeyDown or KeyUp event? It probably applies pretty well if you are pulling keyboard events out of the buffer, too.

Code:
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (key = vk_tab) then
    if ssShift in shift then
      label1.caption := 'Shift + Tab'
    else
      label1.caption := 'Tab';
end;
 
Thank you. Yes i use the onkeydown event. The problem is that my cursor is moving from one field to another when i press shift tab so it is not doing what i want the keys to do. Is there a way, i can disable the jumping from one tedit box to another when using shift tab? I am trying to hide panels when using this key combination.
Thanks.
 
Shift+Tab is the default key combination to move back in the order of focusable controls. Which means you might have a problem on your hands in using that particular key combination for your program - it depends on what functions are necessary and what your users do - doing what is necessary to stop what you are noticing will eliminate keyboard usage of your program.

Anyhow, set TabStop to False for each focusable form control.
 
Thanks..I'll try to set tabstop to false but it sounds like it would also prevent the tab function to work too. I only want Shift-Tab to be disable. Right now I had implemented the backspace key to do what i wanted.This is what i was using:
procedure Tfmain.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (HiWord(GetKeyState(vk_back)) <> 0) and (hidedock=false) then
begin
tooldock.hide;
hidedock:=true;
projectdock.Hide;
end else begin
tooldock.show;
hidedock:=false;
projectdock.Show;
end;
end;

I may want to rethink my captured keystroke.
I'll try to set tabstop to false to see what happens...

Thanks for the tip. If you have a better keystroke combination to hide/show panels, let me know.
PO
 
Yes it will disable the tab function. Like I said, you'll be subverting normal expected functionality.

I was going to say that you can define keystroke combinations for functions in a much easier way than the KeyDown event. When you write captions, if you put & before a letter, then it will underline it, indicating that you can use Alt and then that character to access it. For example, if I define a button to have a caption of &Help, then it will underline the H and then I should be able to use Alt+H to trigger it if my application is active.

Hope that helps.
 
I do use the & for captions but here i'm trying to hide panels. i see what you are saying, i could use a letter in the caption of the panel to hide/show it. This is not a bad idea. I was going to use vk_F2 but may want to change now.
Thanks for the tip. I did not think about that.
PO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top