PowerBuilder Tips
Converting keycodes to character strings
With most objects, you can trap the key strokes using user events. For example, on a datawindow object, you can create a user event using Event Id = pbm_dwnkey. In this event, you'll find a parameter of type keycode. This is a predefined enumerated data type with values such as KeyA!, KeyB!, etc. But if you want to convert this value to a string, you'll find your choices are limited.
I searched for a method, but found none that did not involve a long extended CHOOSE statement. It looks something like this:
CHOOSE CASE a_key // for a..z, we convert to lower case at the end of the function. CASE keyA! ls_Key = 'A' CASE keyB! ls_Key = 'B' CASE keyC! ls_Key = 'C' CASE keyD! ls_Key = 'D' CASE keyE! ls_Key = 'E'Just in case you need this, the source code is available here.
What use is it you ask? Well, I used it on a datawindow to duplicate what you can do with an editable drop down datawindow. For example, it was a list of parts. If you pressed 'J', you went to the parts starting with 'J', etc.
[ About | Services | Products | Search | Feedback | Support ]
This page last updated: Tuesday, 29 February 2000 |