Solved

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

Posted on 2000-04-30
5
267 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
Comment Utility
Labels and Panels is not a Window controls, so that it cann't accept FOCUS!

Motaz
0
 
LVL 9

Expert Comment

by:ITugay
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now