Page 1 of 1

Disable Page Down key functionality in DCCOMBOBOX

Posted: Mon Jul 27, 2015 4:59 pm
by rsmarks
I would like to use Page Down as an ACCELKEY for a DCPUSHBUTTON. Consequently, if a DCCOMBOBOX is currently active, I do not want the Page Down key to select a different entry in the DCCOMBOBOX list. I would like the DCCOMBOBOX to ignore the key. How can I go about doing that. Thx.

Re: Disable Page Down key functionality in DCCOMBOBOX

Posted: Tue Jul 28, 2015 5:00 am
by rdonnay
You could try this:

Code: Select all

 @..DCCOMBOBOX ..  EVAL {|o|o:keyboard := {|a,b,o|IIF(a==xbeK_PGDN,DC_ClearEvents(),nil)}}
I tried it and it worked for me.

You will also need #include "appevent.ch"

Re: Disable Page Down key functionality in DCCOMBOBOX

Posted: Tue Jul 28, 2015 4:43 pm
by rsmarks
Alas, it did not work. I tried:
@ 1,1 DCCOMBOBOX cSlsmn LIST aSlsIDs SIZE 22,8 TYPE XBPCOMBO_DROPDOWNLIST ;
EVAL {|o|o:keyboard := {|a,b,o|IIF(a==xbeK_PGDN,DC_ClearEvents(),nil)}}

Hitting PGDN from the SLE selects the last element in the array. The only time this dues not happen is if I first click on the arrow to open the dropdown box, then hit PGDN. I inserted a dc_alert("???") in front of the dc_clearevents() and noticed the last element was selected from the array and placed in the SLE before the dc_clearevents() had a chance to strip out the PGDN.

Re: Disable Page Down key functionality in DCCOMBOBOX

Posted: Tue Jul 28, 2015 5:10 pm
by Auge_Ohr
hi

i have try it with "pure" Xbase++ : PGDN -> last Array Element is the normal behavior of SLE from a Combobox

try to intercept ::XbpCombo:XbpSLE

Code: Select all

EVAL {|o|o:XbpSLE:keyboard := {|nKeyCode, uNIL,oSelf | ... }

Re: Disable Page Down key functionality in DCCOMBOBOX

Posted: Tue Jul 28, 2015 7:15 pm
by rdonnay
My test program worked.

I will need one from you that does not work.

Please give me a sample program that I can compile and run.

Re: Disable Page Down key functionality in DCCOMBOBOX

Posted: Wed Jul 29, 2015 8:52 am
by rsmarks
Here you go. If I run the program and hit PGDN, the last name will be selected.

By the way, I did try to intercept ::XbpCombo:XbpSLE, but it did not work.

Thanks

#include "dcdialog.ch"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList:={}, GetOptions
LOCAL nSlsHt, lReminder:=.F., cSlsmn1:="1235 Joe Schriber Maximus"
LOCAL aSlsIDs:={SPACE(25),;
"1234 John Jones ",;
"1235 Joe Schriber Maximus",;
"1236 Jane Austin IV ",;
"1237 Last Man Standing "}
nSlsHt:=LEN(aSLSIDS)
@ 1.3,1 DCSAY "SLS ID"
@ 1.3,8 DCCOMBOBOX cSlsmn1 LIST aSLSIDS SIZE 25, nSlsHt ;
TYPE XBPCOMBO_DROPDOWNLIST ;
EVAL {|o| o:keyboard := {|a,b,o|IIF(a==xbeK_PGDN,DC_ClearEvents(),nil)}}
@ 2.3,1 DCCHECKBOX lReminder PROMPT "Create a Followup Reminder"
@ 4.3+nSlsHt/2,8 DCPUSHBUTTON CAPTION 'Ok' SIZE 10,1.3 ;
ACCELKEY xbeK_PGDN ;
ACTION {|| DC_Alert(cSlsmn1+" "+Var2Char(lReminder))}
@ 4.3+nSlsHt/2,19 DCPUSHBUTTON CAPTION 'Cancel' ;
SIZE 10,1.3 ;
ACTION {|| DC_ReadGuiEvent(DCGUI_EXIT_ABORT,GetList)}

DCGETOPTIONS NOCONFIRM

DCREAD GUI TITLE "Add to Wish List" ;
OPTIONS GetOptions CLEAREVENTS NOENTEREXIT ;
FIT MODAL
RETURN NIL


* ---------

PROC appsys
return

* ---------

Re: Disable Page Down key functionality in DCCOMBOBOX

Posted: Wed Jul 29, 2015 11:29 am
by rdonnay
I have found that almost any problem like this can be solved with a custom event handler.
This works very good.

Code: Select all

#include "dcdialog.ch"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList:={}, GetOptions
LOCAL nSlsHt, lReminder:=.F., cSlsmn1:="1235 Joe Schriber Maximus"
LOCAL aSlsIDs:={SPACE(25),;
"1234 John Jones ",;
"1235 Joe Schriber Maximus",;
"1236 Jane Austin IV ",;
"1237 Last Man Standing "}
nSlsHt:=LEN(aSLSIDS)

@ 1.3,1 DCSAY "SLS ID"

@ 1.3,8 DCCOMBOBOX cSlsmn1 LIST aSLSIDS SIZE 25, nSlsHt ;
TYPE XBPCOMBO_DROPDOWNLIST

@ 2.3,1 DCCHECKBOX lReminder PROMPT "Create a Followup Reminder"

@ 4.3+nSlsHt/2,8 DCPUSHBUTTON CAPTION 'Ok' SIZE 10,1.3 ;
ACCELKEY xbeK_PGDN ;
ACTION {|| DC_Alert(cSlsmn1+" "+Var2Char(lReminder))}

@ 4.3+nSlsHt/2,19 DCPUSHBUTTON CAPTION 'Cancel' ;
SIZE 10,1.3 ;
ACTION {|| DC_ReadGuiEvent(DCGUI_EXIT_ABORT,GetList)}

DCGETOPTIONS NOCONFIRM

DCREAD GUI TITLE "Add to Wish List" ;
OPTIONS GetOptions CLEAREVENTS NOENTEREXIT ;
FIT MODAL ;
HANDLER myHandler

RETURN NIL

* ---------

STATIC FUNCTION myHandler( nEvent, mp1, mp2, oXbp )

IF nEvent == xbeP_Keyboard .AND. mp1 == xbeK_PGDN .AND. oXbp:isDerivedFrom('XbpComboBox')
  RETURN DCGUI_IGNORE
ENDIF

RETURN DCGUI_NONE

* ---------

PROC appsys
return

Re: Disable Page Down key functionality in DCCOMBOBOX

Posted: Wed Jul 29, 2015 5:10 pm
by rsmarks
Perfect! Thanks for all your help.

Re: Disable Page Down key functionality in DCCOMBOBOX

Posted: Fri Jul 31, 2015 9:52 pm
by Cliff Wiernik
We also use a custom handler to modify the behavior of the dccombobox and it has worked great for years.