Disable Page Down key functionality in DCCOMBOBOX

This forum is for eXpress++ general support.
Post Reply
Message
Author
rsmarks
Posts: 27
Joined: Tue Nov 26, 2013 9:19 pm

Disable Page Down key functionality in DCCOMBOBOX

#1 Post 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.

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Disable Page Down key functionality in DCCOMBOBOX

#2 Post 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"
The eXpress train is coming - and it has more cars.

rsmarks
Posts: 27
Joined: Tue Nov 26, 2013 9:19 pm

Re: Disable Page Down key functionality in DCCOMBOBOX

#3 Post 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.

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: Disable Page Down key functionality in DCCOMBOBOX

#4 Post 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 | ... }
greetings by OHR
Jimmy

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Disable Page Down key functionality in DCCOMBOBOX

#5 Post 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.
The eXpress train is coming - and it has more cars.

rsmarks
Posts: 27
Joined: Tue Nov 26, 2013 9:19 pm

Re: Disable Page Down key functionality in DCCOMBOBOX

#6 Post 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

* ---------

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Disable Page Down key functionality in DCCOMBOBOX

#7 Post 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
The eXpress train is coming - and it has more cars.

rsmarks
Posts: 27
Joined: Tue Nov 26, 2013 9:19 pm

Re: Disable Page Down key functionality in DCCOMBOBOX

#8 Post by rsmarks »

Perfect! Thanks for all your help.

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Disable Page Down key functionality in DCCOMBOBOX

#9 Post by Cliff Wiernik »

We also use a custom handler to modify the behavior of the dccombobox and it has worked great for years.

Post Reply