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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping for Shift Key

Status
Not open for further replies.

hcts

Programmer
Jan 14, 2004
89
US
Hi, I am new to this thread, but have been programing in PDOX for years. I have what should be an easy question. I have replaced the default Ctrl+Spacebar lookups with my own forms. I am now redesigning these for report lookups. To do this I am wanting to allow the user to go to a tableframe, press shift and arrow down to another record, and then return the first and last value to the originating form. The problem I am having is in trapping for when the user presses the Shift key. I am checking in the KeyPhysical method on the form level for eventinfo.Vchar()="VK_SHIFT" but it does not trigger. I can detect when the shift key is already pressed down and the up or down key is pressed, but I want to know when the shift key is pressed.

Any ideas?, or another way of selecting a range of values from a tableframe?

Thanks,

James D. Howard
 
I don't know how to detect a single keypress of the shift key, only when it is part of a key combination. For multiple selects, I usually add a logical field to the table and make it into a checkbox. The user checks the records they want to include. I usually add a "Check All" and "Uncheck All" too.



Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Thanks for the response. I have setup the check boxes on selection screens before, but wanted to emulate the explorer look and feel. Decided to switch to the F5 key for starting and ending my selection block. Works fine. I also switch the color for the record object and field objects (background and font) so that the user knows what they have selected.

Anyway thanks for the try, I am new to this thread and will try to help out also.
 
Great! Post an example code snippet if you don't mind.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Ok,

Example: We have a number of payroll reports that could be printed out by employee. We want the user to be able to get an up to date list of employees.

Originally we setup a table in the users PRIV dir that used the default table lookup to the employee master file. The problem with that is that the default PDox table lookup has no edit capablility. Didn't look very good either. And in the case of multiple companies, we had to setup multiple PRIV directories and specify where they were with a -p on the icon.

So instead we setup a form with a table frame object on it. That way it looked like the rest of our program. Then on the report form, for the first employee field we added the following code to the action method:

DODEFAULT
IF
EVENTINFO.ID() = DATALOOKUP
THEN
SETMOUSESHAPE(MOUSEWAIT)
MESSAGE("Please wait...")
DISABLEDEFAULT
F.OPEN("PREMPPOP")
SETMOUSESHAPE(MOUSEARROW)
MESSAGE("")
F.WAIT()
ACTIVE.ACTION(FIELDFORWARD)
ENDIF

This traps for the Ctrl+Spacebar, disables the default behavior, then calls the lookup form, and waits for the user to select. Once the selections have been made, the user is moved on to the next selection criteria automatically.

On the lookup form I have three undefined fields, SELECTOR; SFIRST;SLAST. In the Keyphysical method on the form level I trap for wether the F5 key is pressed and whether the selector field is Y or N. I then switch the selector to the other logical value and if the selector is being turned on, I set the SFIRST and SLAST to the employee number value.

On the Arrive method of the record object I run the following code:
DODEFAULT
IF
SELECTOR="Y"
THEN
SWITCH
CASE SFIRST=MAINKEY :
SLAST = MAINKEY
SELECT1()
CASE SFIRST<MAINKEY AND SLAST<MAINKEY:
SLAST = MAINKEY
SELECT1()
CASE SFIRST<MAINKEY AND SLAST>MAINKEY:
SLAST = MAINKEY
SELECT1()
CASE SFIRST>MAINKEY :
SLAST = MAINKEY
SELECT1()
ENDSWITCH
ELSE
ENDIF

The methods SELECT1() and SELECT2() sets my field colors and font color from our default scheme to a black and white inverse scheme.

Finally on the newvalue of the employee number field I put the following code:

DODEFAULT
IF
SELF>=SFIRST AND SELF<=SLAST
THEN
SELECT1()
ELSE
SELECT2()
ENDIF

This sets the color for each record even if the user pages up or down on the MRO.

There is more code that sends the value in the SFIRST and SLAST to the calling form upon the users either pressing return on the employee number or pressing a &quot;SELECT&quot; button on the form.

We also have the ability to password protect what actions the user can or cannot do while on the form. IE: you can lookup but NOT modify, you can modify but NOT add, you can add but NOT delete. Or you can only look at a certain class of employee.

All in all we are fairly happy with the GUI.

BTW; we are neighbors, our offices are in Brookshire Texas, just west of Katy.
 
Cool, I may give that a try.

I like Brookshire and Katy - went out there not long ago and met your Chief of Police. Turns out he was one of my instructors some 21 years ago.

Mac :)

&quot;There are only 10 kinds of people in this world... those who understand binary and those who don't&quot;

langley_mckelvy@cd4.co.harris.tx.us
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top