Solved

How can I assign a tab value to a label or panel?

Posted on 2000-04-30
5
269 Views
Last Modified: 2010-04-04
I want to provide access to labelclicks or panelclicks via the keyboard, using cursor keys or tab to cycle through. Windows lets you do it with the tab value on buttons which is fine, but can I do it with labels and panels which see to have no tab value available?
0
Comment
Question by:chriswood
5 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 2763534
Labels and Panels is not a Window controls, so that it cann't accept FOCUS!

Motaz
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2763637
Hi chriswood.

You can do it with TPanels but not with TLabel. Look at this topic:
-----
Use the TabStop to allow or disallow access to the control using the Tab key. If TabStop is True, the control is in the tab order. If TabStop is False, the control is not in the tab order and the user can't press the Tab key to move to the control.
-----

The TabStop property appears in TWinControl hierarchy level and TLabel have not this property.

To be sure it work with panels try this sample:

1. new app
2. drop four panels on your form
3. drop TEdit
4. drop TTimer
5. set property TPanel1..4.TabStop = true

6. write TTimerTimer event like this:

procedure TForm1.Timer1Timer(Sender: TObject);
begin
   if ActiveControl is TPanel
   then Edit1.Text:=TPanel(ActiveControl).Name;
end;

7. run your app
8. press [tab] or [arrow] keys to see ActiveControl name.

------
Igor.

0
 
LVL 3

Expert Comment

by:sburck
ID: 2763788
When I try to do panel selection, I usually keep all panels without a border until they are selected.  In a single, combined OnEnter and OnExit method for all the selectable panels I have this code:

procedure TForm1.PanelEnter(Sender: TObject);
begin
     (Sender as TPanel).BorderStyle = bsSingle;
end;

procedure TForm1.PanelExit(Sender: TObject);
begin
     (Sender as TPanel).BorderStyle = bsNone;
end;
 
Put a bunch of panels on your form, give all of their OnEnter's the PanelEnter method, all of their OnExit's the PanelExit method, and run it.  Tabbing between them is very clear.

You can do other things like changing colors, but this is simple and effective.
0
 

Author Comment

by:chriswood
ID: 2763824
Yep, thanks guys, I missed panel had a tab value... (duh)

but does anyone have a method for using tab or cursor keys on non-tab objects such as labels...?  That's what I really want...

but thanks for the tip about the border, (sburck) I like that.
 
0
 
LVL 3

Accepted Solution

by:
sburck earned 100 total points
ID: 2763839
Here, Motaz is right - any control which isn't a Window control can't get a focus.  Here, too, though, you can fake it using a panel.  Shrink the panel to the size of the label, make it 'invisible' (bevelinner & bevelouter to bvnone), and change the fontstyle of the caption on the onenter and onexit.
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…

832 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