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

CommandGroup wrapping/looping 1

Status
Not open for further replies.

Goofus828

Programmer
Nov 9, 2005
127
0
0
US
Hi All,
been out of the coding world for a while now back into it!

I have a container with a 7 button command group.
The buttons are vertically placed.

When I arrow down and get the the 7th button, i want to reposition to the first button when I press the down arrow on the 7th button, but instead it moves to the next object outside the cmdgrp & container

I won't bore you with all the coding that I tried but most of them did not work.

I did try this and did not get the expected results

in the Thisform.Container.commandgroup.command7.keypress
Code:
IF nkeycode = 24 && downarrow
[indent]Thisform.Container.commandgroup.command1.SetFocus [/indent]
ENDIF

This puts me on the 2nd command button in the commandgroup!

any help or hints would be appreciated!
Thanks
 
2 questions...

1. Are your individual buttons sequentially named: command1, command2, command3, command4, command5, command6 & command7 ?
Or when you look at the Form's properties you find that they have different names?​
And you have not re-arranged their original button order such that their names are no longer sequentially numbered? (Click on each button and individually examine the Property Name)​

2. Have you used SET STEP ON to automatically open your TRACE Window and then Single Step to watch your code execute?
Code:
IF nkeycode = 24 && downarrow
[indent]SET STEP ON [/indent]
[indent]Thisform.Container.commandgroup.command1.SetFocus  [/indent]
ENDIF

Good Luck,
JRB-Bldr

 
...Because you didn't do NODEFAULT. Keypress event happens before keys are really processed. So setting focus to button1 and exiting the code, the downarrow still works and puts the focus on button2, that's all there is to it. The event order is natural, otherwise Keypress wouldn't enable you to suppress keystrokes or replace them with other keystrokes.

So you do
Code:
IF nKeyCode = 24 AND nShiftAltCtrl = 0 && downarrow
   Thisform.Container.commandgroup.command1.SetFocus 
   NODEFAULT
ENDIF
If you don't check for nShiftAltCtrl =0, but only check for nkeycode = 24 you also will react to CTRL+X and ALT+O, these combinations cause the same nKeyCode 24.

Bye, Olaf.
 
The button are sequential 1-7 and the tab order is 1-7. no change with any of that.

 
Olaf, that was it!
you just saved me a ton of spaghetti code to work around this.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top