Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Arrow Key Trapping in ComboBox
Message
De
09/09/1999 08:05:54
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00261393
Message ID:
00262773
Vues:
21
Paul:

Here is some sample code that I added to my combobox keypress event. When the style is dropdown combo (1), the Up/Down arrows act differently than when it dropdown list (2). I added a custom property ListIsDown to the control. I also tried the dropdown event, but couldn't get the behavior I wanted. The Keyboard '{F4}' is a keyboard shorcut that drops down the list when style is 1. Alt-Down or Alt-Up does the same. Once either style box is dropped, the up/down moves up and down the list, as you asked.


* BEGIN FORM1.MVCOMBOBOX.KEYPRESS()
* Description:
* Parameters: -
* Returns:
* Notes: 1.
* 2.
* Revisions: 08/23/1999 - MWT
* - Created

lparameters nKeyCode, nShiftAltCtrl

do case
case nKeyCode = 5 && Ignore Up Arrow
if (this.style = 0 AND !this.ListIsDown)
nodefault
this.ListIsDown = .T.
KEYBOARD '{F4}'
else
dodefault(nKeyCode, nShiftAltCtrl)
endif

case nKeyCode = 24 && Ignore Dn Arrow
if (this.style = 0 AND !this.ListIsDown)
nodefault
this.ListIsDown = .T.
KEYBOARD '{F4}'
else
dodefault(nKeyCode, nShiftAltCtrl)
endif

otherwise
* Grab the keystroke and figure out what to do with it.
this.nLastKey = nKeyCode
this.nLastModifier = nShiftAltCtrl
this.HandleKey()
if this.lHandled
nodefault
if this.lSearch
this.Search()
endif
else
dodefault(nKeyCode, nShiftAltCtrl)
endif
endcase

RETURN

* END FORM1.MVCOMBOBOX.KEYPRESS()

I turn the custom property off in Lostfocus.

* BEGIN FORM1.MVCOMBOBOX.LOSTFOCUS()
* Description:
* Parameters: -
* Returns:
* Notes: 1.
* 2.
* Revisions: 08/24/1999 - MWT
* - Created

dodefault()
this.ListIsDown = .F.

* END FORM1.MVCOMBOBOX.LOSTFOCUS()

BTW, If you want an keypress to perform the same function as a when the lsit is dropped, sub-class the combobox and put the following code in it's keypress event:


* BEGIN FORM1.DATAENTRYCOMBOBOX.KEYPRESS()
* Description: Added to allow an to act like a when the user is in the list
* part of a drop-down combo on a maintenance form.
* Parameters: -
* Returns:
* Notes: 1.
* 2.
* Revisions: 09/01/1999 - MWT
* - Created

lparameters nkeycode,nshiftaltctrl

do case
case nKeyCode = 13
this.ListIsDown = .F.
KEYBOARD '{TAB}'
nodefault
otherwise
dodefault(nkeycode,nshiftaltctrl)
endcase

* END FORM1.DATAENTRYCOMBOBOX.KEYPRESS()

You need the sub-class so that when you have a combobox on a form and you want to allow the to execute the default control (ususally a command button), you can use the mvCombobox and use the dataentrycombobox (my names) when you want to act as an advance to the next control.

HTH
Mike
Mike
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform