Solved

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

Posted on 2000-04-30
5
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

632 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