Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems with KeyPress
Message
From
16/03/2018 03:01:44
 
 
To
15/03/2018 06:20:08
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 10
Network:
Windows Server 2012 R2
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01658762
Message ID:
01658778
Views:
59
>>I am trying to make a keypress work to capture CTRL+c. However that seems to be a reserved key and the keypress does not trigger at all. Same for Ctrl+x and Ctrl+v. All other keys as well as Ctrl+Shift+c do work.
>>
>>So I am trying to find a workaround to recognize the event if that key is being pressed, but so far no luck. Any suggestions would be highly appreciated.
>
>Ctrl-c is reserved, as you have noticed. If you want the key combination to work as most people expect, read here for some tips: http://www.tek-tips.com/viewthread.cfm?qid=823135
>
>I am very interested in see what solution you end p with.

I got it to work, however it was a little bit tricky. One thing that can be really confusing is, that when the debugger is open, Keypress just works normal with Ctrl+c. So you think it is working good while in fact it is not, which you realize once you closed the debugger. And they say, the debugger is your friend, well in that case he is clearly not your friend.

Second problem: Grid with Allowcellselection=.F. does not trigger SetFocus(), and GotFocus() event does not exist. So I used When and Valid, both are working surprisingly consistent and reliable.

I did not want to use _SCREEN.ActiveForm, so I used my event handler, which works great. In the When event I initialize the eventhandler and the Ctrl+c raises the custom event, which gets redirected to the controls custom method:
LOCAL loEvents AS Events OF eventhandler.vcx
loEvents = MakeObject("Events","eventhandler.vcx")
loEvents.ListenTo("OnCtrl_c",THIS)

ON KEY LABEL Ctrl+c EXECSCRIPT([loEvents = MakeObject("Events","eventhandler.vcx")] ;
		+ CHR(13) + [loEvents.RaiseEvent("OnCtrl_c")])

RETURN .T.
Christian Isberner
Software Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform