Topic: simulate a tab key

Hello MVD funs
please how can i create a button to simulate a tab key or a tab+shift key.
I want to move selection from one editbox to an other by that button.
Thabk you.

Re: simulate a tab key

Hello.


You can set focus to the next component, using this code:

Form1.SetFocusNextControl; 

but you can't use this method by click on button, because when you click on a button, you set focus on this button.

Dmitry.

Re: simulate a tab key

Thank you.
but i mean  how to send a key to the form or a combinition of keys. like "keybd-event" or "sendkey()".
i dont want to use pc keybord in  my application.

Re: simulate a tab key

There is no function to send a key to the form.


Why you don't want to use SetFocusNextControl method?

Dmitry.

Re: simulate a tab key

thank you for response.
first you say that i coud not use it with a button.

second i want to simulate a numpad keys in my form. to input numbers to multiple fields.
i m using a tablet. so i dont want to use the embaded  virtual keybord to save space.

Re: simulate a tab key

hichame

Maybe the attached will help you.

Post's attachments

Attachment icon Next Form Field.zip 580.74 kb, 53 downloads since 2017-09-11 

Re: simulate a tab key

Hi EHW,
I had a look at this problem but was going for the no-script option as always (only joking!).
It's a neat solution - nice one.
Derek.

Re: simulate a tab key

hello
thank you ehwagner for this solution. I will try to use it . But it would be more easy if there was a function to simulate a key in one button . Especially whene there is a large number of fields in the form.

Re: simulate a tab key

hichame wrote:

hello
thank you ehwagner for this solution. I will try to use it . But it would be more easy if there was a function to simulate a key in one button . Especially whene there is a large number of fields in the form.

Example:

procedure SendKeyForAllEdits(Form: TAForm; sKey: string);
var
    i,c: integer;
begin
    c := Form.ComponentCount-1;
    for i := 0 to c do
    begin
        if Form.Components[i] is TdbEdit then TdbEdit(Form.Components[i]).Text := TdbEdit(Form.Components[i]).Text + sKey;
    end;

end;

procedure Form1_Button3_OnClick (Sender: string; var Cancel: boolean);
begin
    SendKeyForAllEdits(Form1, '1'); // how to use
end;
Dmitry.

Re: simulate a tab key

thank you for your example.