Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2000-04-30
5
Medium Priority
?
275 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 300 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

972 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