Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
On key label triggers button click
Message
From
27/10/2002 19:00:30
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00715908
Message ID:
00715919
Views:
15
>Hi,
>
>I have a form with a command button whose click event is also triggered by ON KEY LABEL F2.
>The event does fire. However, I would like the visual button click to show.
>How can I do this?

First, avoid On Key Label. There are other ways. The reason for this is that OKL runs out-of-context; it doesn't know the name of your form, has no sure way to reference it etc etc. Even if you made it run a .prg file, that file would need to find your form first - probably by traversing _screen.forms collection and looking for a button with a given caption, name or some other distinguishable property.

Two safer ways would be to either have a (optionally hidden) menu on the form which would have a hotkey for F2, or to have form.KeyPreview=.t., and to capture the case where nKeyCode=-1 (AFAIK, that's the code for F2) in form.keypress method. I'd prefer the latter, because that way everything is contained within the form.

Alternately (but this is a kludge, and I'm not sure it would work), you could have a hotkey on your button, if you include a "\<" string before the hotkey character in button's caption. If button.caption="Bu\ .Signature { margin-top: 12px; color: #666666; } .Signature a { color: #666666; }

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform