Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing active pageframe page with keyboard

Status
Not open for further replies.

csr

Programmer
Jul 20, 2000
507
I have a form with 2 pages on a pageframe. I would like to allow the user to press a key which will toggle the active page from one to the other. What might be the best means to accomplish this ?


Don


 
MyForm.KeyPressEvent

IF nKeyCode = 9 && Tab (suggest use some other key)
IF ThisForm.PageFrame1.ActivePage = ;
ThisForm.PageFrame1.PageCount
ThisForm.PageFrame1.ActivePage = 1
ELSE
ThisForm.PageFrame1.ActivePage = ;
ThisForm.PageFrame1.ActivePage + 1
ENDIF
NODEFAULT
ENDIF

MyForm.KeyPreview = .t.


however, try to use some other key than TAB, since the TAB is the normal key used to jump from control to control.

:)

____________________________________________
ramani - (Subramanian.G) :)
 

Have you looked at the help files on ON KEY LABEL ?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
All you have to do is set the .TabStop property of the pageframe to .T., then the user can tab through all the textboxes & buttons, etc, and once the focus is on the tabs, the arrow keys select which tab is on top.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Hello Don.

I would strongly advise against using an ON KEY LABEL. The reason for this is that an OKL will fire and interrupt any code that happens to be running at the time. You would be much better of to set the form;s KeyPreview property to tru and trap for keystrokes in the form's KeyPress method.

Marcia G. Akins
 
Hello csr,

I am certainly not one of the advanced users around here. But I did a similar thing in an app of mine, and I found that using the \< character on the tab caption of each page acts as a page changer.

Ex: \<Entries & \<Help as captions of the two pages would allow Alt+E and Alt+H to go to the appropriate page.

But, a big gotcha... if there are any identical \< hot keys on the page (not the pageframe), they will take precedence.

BillvV
 
Thank you all for your assistance. There are many good ideas here from which I will look for my final solution.


Don


 
Will do. However, I may not get to that for a while as I have other pressing matters on my plate.


Don


 
Ok ... here is what I ended up with:

I set myform.Keypreview = .t.
In myform.keypressEvent I have ...

LPARAMETERS nKeyCode, nShiftAltCtrl
IF nKeyCode = 18 && PageUp
IF thisform.pageframe1.ActivePage=1
thisform.pageframe1.ActivePage=2
ELSE
thisform.pageframe1.ActivePage=1
ENDIF
NODEFAULT
ENDIF


Here are some other comments or observations ...

Using Ctrl-Tab works ... however ... you have to move through all of the controls on the form before you get to the page frame tabs so that is not workable.

I had originally tried using the myform.KeypressEvent method earlier and had tried to use the F12 key and it didn't work so I went to tek-tips for help. Well, it turns out the none of the Function keys seem to process through the KeypressEvent method. At least that was my experience, so I used the PAGEUP key instead.

The \<Hot \<Key concept works but not when I am editing a field when I try to switch pages.

Any of the other thoughts/ideas I left for another time.


So, all in all, things worked out fine and thanks again for your assistance.




Don


 
, it turns out the none of the Function keys seem to process through the KeypressEvent method

This is probably because there are the default SET FUNCTION commands in effect. you might try: CLEAR MACROS
or
SET FUNCTION 1 TO
SET FUNCTION 2 TO
etc.
before using the F-keys

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Ok ... If I revisit this feature I will look into that. thanks.


Don


 
I concur with Ramani, Marcia, and the others that recommend keypress. Stay away from on key label, espeically on forms. You cannot trap / debug onkey and you lose control.

This FAQ describes the Keypress in detail.

KEYPRESS Event instead of ON KEY LABEL faq184-4097



Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top