Discussion:
Problem with tab order and group box
(too old to reply)
fig000
2008-05-01 17:00:24 UTC
Permalink
Hi,

I'm somewhat new to delphi. Due to the needs of the app which runs
on a scan gun with a limited keyboard, I'm actually tabbing using the
enter key. Basically when they hit the enter key, it's trapped and
the
program does the following:


SelectNext(ActiveControl, True, True);


It works fine except for when I try to "tab" to the first field in a
group box with two controls (a listbox and an tedit). What always
happens is that it goes to the second control in the group box and
the
first control never gets focus. I've checked the tab order with in
the
group box in the properties and by right clicking the group box. Also
the group box has the correct tab order within the controls on the
page (i'ts the third control).


I tried reversing the tab order with in the group box by right
clicking and choosing tab order, just to see what happens. In this
case I do get to the first control when I hit enter, but the second
one never gets focus.


I have a feeling that when it hits the groupbox in the tab order
it's automatically going to the first control and then the SelectNext
is sending it right to the second. I've tried not doing the
SelectNext
if I'm in the groupbox (testing groupbox.focused) or in the first of
the two controls (listbox.focused). In neither case does focus seem
to
detect that I'm in the groupbox so it doesn't work.


I'm a newbie so please bear with me. Any help would be appreciated.


Fig000
Hans-Peter Diettrich
2008-05-01 18:47:14 UTC
Permalink
Post by fig000
I have a feeling that when it hits the groupbox in the tab order
it's automatically going to the first control and then the SelectNext
is sending it right to the second.
Right, a groupbox cannot have the focus (i.e. receive keyboard input),
it will give the focus to it's first child control.
Post by fig000
I've tried not doing the SelectNext
if I'm in the groupbox (testing groupbox.focused) or in the first of
the two controls (listbox.focused). In neither case does focus seem
to detect that I'm in the groupbox so it doesn't work.
... because the groupbox can not have the focus.

I have no cure for your problem, it might depend on your Delphi version,
and on the Windows version on the device - WinCE?

DoDi
Fons
2008-05-01 21:49:18 UTC
Permalink
Are you trapping with

procedure FormKeyPress(Sender: TObject; var Key: Char);

?

Instead of KeyPress try

procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);

And/or abort all other processing of the Enter key.

Fons.
Post by fig000
Hi,
I'm somewhat new to delphi. Due to the needs of the app which runs
on a scan gun with a limited keyboard, I'm actually tabbing using the
enter key. Basically when they hit the enter key, it's trapped and
the
SelectNext(ActiveControl, True, True);
It works fine except for when I try to "tab" to the first field in a
group box with two controls (a listbox and an tedit). What always
happens is that it goes to the second control in the group box and
the
first control never gets focus. I've checked the tab order with in
the
group box in the properties and by right clicking the group box. Also
the group box has the correct tab order within the controls on the
page (i'ts the third control).
I tried reversing the tab order with in the group box by right
clicking and choosing tab order, just to see what happens. In this
case I do get to the first control when I hit enter, but the second
one never gets focus.
I have a feeling that when it hits the groupbox in the tab order
it's automatically going to the first control and then the SelectNext
is sending it right to the second. I've tried not doing the
SelectNext
if I'm in the groupbox (testing groupbox.focused) or in the first of
the two controls (listbox.focused). In neither case does focus seem
to
detect that I'm in the groupbox so it doesn't work.
I'm a newbie so please bear with me. Any help would be appreciated.
Fig000
a***@aol.com
2008-05-02 12:07:42 UTC
Permalink
It works OK for me with D3, tabbing in order Edit2,
GroupBox1.ListBox1, GrouoBox1.Edit1, CheckBox1 with Enter, with
either ...

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If (Key = VK_RETURN) then
SelectNext(ActiveControl, True, True);
end;

...or ...

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
If (Key = #13) then
SelectNext(ActiveControl, True, True);
end;

with ,,,

TForm1 = class(TForm)
Edit2: TEdit; // tab order 0
GroupBox1: TGroupBox; // tab order 1
ListBox1: TListBox; // tab order 0
Edit1: TEdit; // tab order 1
Edit3: TEdit; // tab order 2
CheckBox1: TCheckBox; // tab order 3

...and with the Form's KeyPreview set to true.

Alan Lloyd
Bart
2008-05-05 10:45:02 UTC
Permalink
Op Thu, 1 May 2008 10:00:24 -0700 (PDT) schreef fig000
Post by fig000
Hi,
I'm somewhat new to delphi. Due to the needs of the app which runs
on a scan gun with a limited keyboard, I'm actually tabbing using the
enter key. Basically when they hit the enter key, it's trapped and
the
SelectNext(ActiveControl, True, True);
It works fine except for when I try to "tab" to the first field in a
group box with two controls (a listbox and an tedit). What always
happens is that it goes to the second control in the group box and
the
first control never gets focus. I've checked the tab order with in
the
group box in the properties and by right clicking the group box. Also
the group box has the correct tab order within the controls on the
page (i'ts the third control).
I tried reversing the tab order with in the group box by right
clicking and choosing tab order, just to see what happens. In this
case I do get to the first control when I hit enter, but the second
one never gets focus.
I have a feeling that when it hits the groupbox in the tab order
it's automatically going to the first control and then the SelectNext
is sending it right to the second. I've tried not doing the
SelectNext
if I'm in the groupbox (testing groupbox.focused) or in the first of
the two controls (listbox.focused). In neither case does focus seem
to
detect that I'm in the groupbox so it doesn't work.
I'm a newbie so please bear with me. Any help would be appreciated.
Fig000
Are you sure the control that you cannot reach does not have (by
mistake) the TabStob value set to false ?

Bart
--
Bart Broersma
***@tiscali.nl
(ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)
Loading...