DCCOMBOBOX arrow keys

This forum is for eXpress++ general support.
Post Reply
Message
Author
zolifree
Posts: 35
Joined: Sun Sep 19, 2010 6:55 am

DCCOMBOBOX arrow keys

#1 Post by zolifree »

Hello,

I use DCCOMBOBOX TYPE XBPCOMBO_DROPDOWNLIST together with DCGETs.
I want to use the Up/Down arrows to move to a get object I want to change, but when I reach the DCCOMBOBOX objects, the Up/Down arrow changes the walue instead of moving to the next get object.
I tried many ways to solve this, but I was not able to find a good solution.
I want to change the value of DCCOMBOBOX by Left/Right arrow.

Another problem with DCCOMBOBOX , I am not able to open the list by pressing Ctrl+ENTER, only the mouse click opens the list.

Best regards,
Zoltan

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

Re: DCCOMBOBOX arrow keys

#2 Post by rdonnay »

Controlling behavior of the XbpComboBox() class has never been easy.
The below sample shows how using different eXpress++ options such as ENTERTAB and also a custom handler can do everything you want except for Ctrl-Enter.

You may want to use the @ DCGET .. COMBO option instead. This is also included in the below sample.

Code: Select all

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

FUNCTION Main()

LOCAL GetList[0], aGets[5], cCombo, aList, GetOptions, oCombo

cCombo := 'Combo 0'
AFill(aGets,Space(20))
aList := {'Combo 1','Combo 2', 'Combo 3' }

@ 0,0 DCGET aGets[1]
@ 1,0 DCGET aGets[2]
@ 2,0 DCCOMBOBOX cCombo TYPE XBPCOMBO_DROPDOWNLIST LIST aList SIZE 10,6 OBJECT oCombo
@ 3,0 DCGET aGets[3] COMBO HEIGHT 4 WIDTH 10 DATA aList
@ 4,0 DCGET aGets[4]
@ 5,0 DCGET aGets[5]

DCGETOPTIONS ;
   ENTERTAB ;
   TABSTOP

DCREAD GUI FIT ADDBUTTONS TITLE 'Combo Test' ;
   HANDLER myHandler OPTIONS GetOptions ;
   EVAL {||(wtf oCombo)}

RETURN nil

* ---------

PROC appsys ; RETURN

* ---------

STATIC FUNCTION MyHandler( nEvent, mp1, mp2, oXbp, oDlg, GetList )

IF nEvent == xbeP_Keyboard .AND. oXbp:isDerivedFrom('XbpComboBox')
  IF mp1 == xbeK_DOWN
    PostAppEvent(xbeP_Keyboard, xbeK_TAB,, oXbp )
    RETURN DCGUI_IGNORE
  ELSEIF mp1 == xbeK_UP
    PostAppEvent(xbeP_Keyboard, xbeK_SH_TAB,, oXbp )
    RETURN DCGUI_IGNORE
  ELSEIF mp1 == xbeK_CTRL_ENTER
    // cannot find a solution
    RETURN DCGUI_IGNORE
  ENDIF
ENDIF

RETURN DCGUI_NONE
The eXpress train is coming - and it has more cars.

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

Re: DCCOMBOBOX arrow keys

#3 Post by Auge_Ohr »

zolifree wrote:Another problem with DCCOMBOBOX , I am not able to open the list by pressing Ctrl+ENTER, only the mouse click opens the list.
try F4 when Combobox have Focus ;-)

Code: Select all

  ELSEIF mp1 == xbeK_CTRL_ENTER
    PostAppEvent(xbeP_Keyboard,xbeK_F4,,oXbp)
    RETURN DCGUI_IGNORE
  ENDIF
greetings by OHR
Jimmy

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

Re: DCCOMBOBOX arrow keys

#4 Post by rdonnay »

Pressing F4 works, but pushing into the event queue doesn't work.
It appears that some mouse and keyboard behavior is hard coded into the class without going thru handleEvent().

I rewrote the sample using a SubClass instead of a custom handler.

Code: Select all

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

FUNCTION Main()

LOCAL GetList[0], aGets[5], cCombo, aList, GetOptions, oCombo

cCombo := 'Combo 0'
AFill(aGets,Space(20))
aList := {'Combo 1','Combo 2', 'Combo 3' }

@ 0,0 DCGET aGets[1]
@ 1,0 DCGET aGets[2]
@ 2,0 DCCOMBOBOX cCombo TYPE XBPCOMBO_DROPDOWNLIST LIST aList ;
      SIZE 10,6 OBJECT oCombo SUBCLASS 'MyComboBox()'
@ 3,0 DCGET aGets[3] COMBO HEIGHT 4 WIDTH 10 DATA aList
@ 4,0 DCGET aGets[4]
@ 5,0 DCGET aGets[5]

DCGETOPTIONS ;
   ENTERTAB ;
   TABSTOP

DCREAD GUI FIT ADDBUTTONS TITLE 'Combo Test' ;
   OPTIONS GetOptions 

RETURN nil

* ---------

PROC appsys ; RETURN

* ---------

CLASS myComboBox FROM DC_XbpComboBox

EXPORTED:

INLINE METHOD Init(a,b,c,d,e,f,g,h)

::DC_XbpComboBox:init(a,b,c,d,e,f,g,h)

RETURN self

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

INLINE METHOD Keyboard(a,b,c)

IF a == xbeK_DOWN
  a := xbeK_TAB
ELSEIF a == xbeK_UP
  a := xbeK_SH_TAB
ELSEIF a == xbeK_CTRL_ENTER
  a := xbeK_F4
ENDIF

RETURN ::xbpComboBox:keyboard(a,b,c)

ENDCLASS
The eXpress train is coming - and it has more cars.

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

Re: DCCOMBOBOX arrow keys

#5 Post by Auge_Ohr »

rdonnay wrote:Pressing F4 works, but pushing into the event queue doesn't work.
It appears that some mouse and keyboard behavior is hard coded into the class without going thru handleEvent().
i forgot that ... need "virtual" Key Constante

Code: Select all

//
//    need VK_ Constante
//
      sendmessageA(oDPick:hDPick,WM_KEYDOWN,VK_F4,0)
      sendmessageA(oDPick:hDPick,WM_KEYUP  ,VK_F4,0)
or

Code: Select all

#DEFINE VK_F4              0x73
#DEFINE KEYEVENTF_KEYUP    0x0002

      IF oChild:isDerivedFrom("XbpComboBox")
         SetAppFocus(oChild)
         keybd_event( VK_F4, 0, 0, 0 )
         keybd_event( VK_F4, 0, KEYEVENTF_KEYUP, 0 )
      ENDIF

FUNCTION keybd_event( nVk, nScan, nFlags, nExtraInfo )
STATIC keybd_event
   IF keybd_event = NIL
      keybd_event := DllPrepareCall( "user32.dll", DLL_STDCALL, "keybd_event" )
   ENDIF
RETURN DllExecuteCall( keybd_event, nVk, nScan, nFlags, nExtraInfo )
greetings by OHR
Jimmy

zolifree
Posts: 35
Joined: Sun Sep 19, 2010 6:55 am

Re: DCCOMBOBOX arrow keys

#6 Post by zolifree »

Roger,

it is not working as expected.
The Ctrl+Enter is not working, but if I change it to any other key, it works with that.
In my program the Ctrl+Enter closes the window with the subclass or handler, but without them nothing happen when I press the Ctrl+Enter.
And if I open the list with F4 or other key, the Up/Down arrow not working, becuse it is translated to TAB or Shift+TAB.

The sublclass and the handler version has this problem too.

Zoltan

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

Re: DCCOMBOBOX arrow keys

#7 Post by rdonnay »

I give up on this.

That is why I added the COMBO feature to @ DCGET many years ago.
The eXpress train is coming - and it has more cars.

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

Re: DCCOMBOBOX arrow keys

#8 Post by Cliff Wiernik »

This is what I use for the DCCOMBOBOX. It provides for use of the down arrow key in the combobox to open up the list. Enter moves to the next object. Up arrow moves to the prior field if listbox is not opened. Tab closes the list box and moves to the next field or moves to the next field. Shift-Tab moves to the prior field but you need to put a tabstop on the prior field.

I liked the behavior I saw on some websites where pressing the down arrow opened the list. Then the down/up arrow navigates the list.

Cliff

Code: Select all


*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
*+
*+      Function LB_Handler( nEvent, mp1, mp2, oXbp, oDlg, aGetlist, aRef, lOk, aApp )
*+
*+        // custom handler that checks for various items
*+
*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
*+

FUNCTION LB_Handler( nEvent, mp1, mp2, oXbp, oDlg, aGetlist, aRef, lOk, aApp )
  LOCAL lPostApp := .F., xCargo

  IF nEvent == xbeP_Keyboard

    // Specialized code to handle combobox processing

    IF oXbp:isDerivedFrom('DC_XbpComboBox')
      IF ((mp1 >= xbeK_ALT_A .AND. mp1 <= xbeK_ALT_Z) .or. mp1 == xbeK_CTRL_F6)   // PC JAC 06-07-04
        IF !oXbp:ListBoxFocus()
          PostAppEvent(xbeP_Keyboard,mp1,,oDlg)
        ELSE
          oXbp:ListBoxFocus(.F.)
          oXbp:keyboard(xbeK_ENTER)
          DC_GetRefresh(aGetlist)
          oDlg:keyboard(mp1)
        ENDIF
      ELSE
        IF !oXbp:ListBoxFocus()
          IF mp1 == xbeK_HOME .OR. mp1 == xbeK_END
            RETURN DCGUI_IGNORE
          ENDIF
          IF mp1 == xbeK_UP
          oDlg:keyboard(xbeK_SH_TAB)
            RETURN DCGUI_IGNORE
          ENDIF
          IF mp1 == xbeK_DOWN 
            oXbp:ListBoxFocus(.T.)
            RETURN DCGUI_IGNORE
          ENDIF
          IF mp1 == xbeK_PGDN 
            PostAppEvent(xbeP_Keyboard,xbeK_PGDN,,oDlg)
            RETURN DCGUI_IGNORE
          ENDIF
        ELSE
          IF mp1 == xbeK_ESC
            oXbp:XbpSle:Undo()
            oXbp:ListBoxFocus(.F.)
            RETURN DCGUI_IGNORE
          ENDIF
          IF mp1 == xbeK_PGDN 
            oXbp:keyboard(xbeK_ALT_UP)
            oXbp:keyboard(xbeK_ENTER)
            PostAppEvent(xbeP_Keyboard,xbeK_PGDN,,oDlg)
            RETURN DCGUI_IGNORE
          ENDIF
          IF mp1 == xbeK_TAB 
            oXbp:keyboard(xbeK_ALT_UP)
            oXbp:keyboard(xbeK_TAB)
            RETURN DCGUI_IGNORE
          ENDIF
        ENDIF
      ENDIF
    ENDIF
    
  ENDIF
      
  RETURN DCGUI_NONE


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

Re: DCCOMBOBOX arrow keys

#9 Post by rdonnay »

Nice work, Cliff. Thanks.

BTW - Call me when you have a chance. I have been working with WSDL and have made a lot of progress.
The eXpress train is coming - and it has more cars.

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

Re: DCCOMBOBOX arrow keys

#10 Post by Cliff Wiernik »

Will do later this week. I can show you my implementation and one issue I have with xml (I have to get together the sample). I worked around it via brute force but while it works, something else may be easier. We went live with it last week and it appears to be working well.

Post Reply