Page 1 of 1

DCCOMBOBOX

Posted: Fri Feb 14, 2025 10:23 am
by MIGUELON
Hi everyone, does anyone know how I can disable pressing the up or down arrow when the focus is on a DCCOMBOBOX?
I want to be able to select only with the right button.
Regards and thanks for your help

Re: DCCOMBOBOX

Posted: Fri Feb 14, 2025 11:06 am
by rdonnay
It would require a change to express++ source code to allow a select from the right mouse button.
Do you also want to disable the left mouse button?

Re: DCCOMBOBOX

Posted: Fri Feb 14, 2025 1:03 pm
by MIGUELON
Thanks for the reply Roger
I don't want to disable any mouse buttons I just want the Up or Down keys to not be able to select any option from the dccombobox array. I use Xbase 1.9

Re: DCCOMBOBOX

Posted: Sat Feb 15, 2025 9:13 am
by rdonnay
Here is an example of how to disable keys in the combobox using a custom event handler:

Code: Select all

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

FUNCTION Main()

LOCAL GetList[0], GetOptions, aComboCaptions, aComboValues, ;
      bGetSet, cComboCaption, nComboValue, oComboBox

aComboCaptions := { ;
    'Nineteen Ninety Seven' , ;
    'Nineteen Ninety Eight' , ;
    'Nineteen Ninety Nine' , ;
    'Two Thousand' , ;
    'Two Thousand One' , ;
    'Two Thousand Two' , ;
    'Two Thousand Three' , ;
    'Two Thousand Four' , ;
    'Two Thousand Five' }

aComboValues := { ;
    1997, ;
    1998, ;
    1999, ;
    2000, ;
    2001, ;
    2002, ;
    2003, ;
    2004, ;
    2005 }

cComboCaption := ''
nComboValue := 2002

@ 1,1 DCSAY 'Choose a year' SAYSIZE 0 SAYBOTTOM

bGetSet := DC_ComboGetSetBlock( aComboCaptions, aComboValues, ;
                                @cComboCaption, @nComboValue )

@ 1, DCGUI_COL + 10 DCCOMBOBOX bGetSet ;
       LIST aComboCaptions ;
       SIZE 20, 10 ;
       OBJECT oComboBox ;
       ITEMSELECTED DC_ComboSelectedBlock( aComboCaptions, aComboValues,  ;
                                           @cComboCaption, @nComboValue )

DCREAD GUI FIT ADDBUTTONS TITLE 'Combobox Test' HANDLER myHandler REFERENCE @oComboBox

DCMSGBOX 'You selected the year ' + Alltrim(Str(nComboValue))

RETURN nil

* ------------

PROC appsys
RETURN

* ------------

STATIC FUNCTION myHandler(nEvent,mp1,mp2,oXbp,oDlg,GetList,oComboBox)

IF nEvent == xbeP_Keyboard .AND. oXbp == oComboBox
  RETURN DCGUI_IGNORE
ENDIF

RETURN DCGUI_NONE

Re: DCCOMBOBOX

Posted: Sun Feb 16, 2025 1:24 pm
by MIGUELON
Thank you very much Roger, this is the solution I was looking for.
I had a dccombobox and a dcbrowse in the same window, when I moved through the rows of the dcbrowse with the up or down keys it sometimes jumps to the dccombobox and starts selecting options from the array.
The problem is solved
:clap: :clap: :clap:

Re: DCCOMBOBOX

Posted: Mon Feb 17, 2025 6:44 am
by SlavkoDam
By your description, the cause of the problem is in dcbrowse and not in dccombobox???? You should handle dcbrowse keys and not dccombobox keys.