Documentation dcread gui example 2

This forum is for eXpress++ general support.
Post Reply
Message
Author
skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Documentation dcread gui example 2

#1 Post by skiman »

Hi Roger,

I think there must be added something to the example 2 of the DCREAD GUI documentation. In that sample there is an array aButton which is used in the event handler.

Code: Select all

--- Example 2 ---

This example shows how to use the DCGUI_NOHOTKEY return value
in a custom handler.  Return this value from any custom event 
handler to disable the hotkey processing of the event.  This was 
added to solve a problem with a customer who used ACCELKEY 
parameters of xbeK_CTRL_M (ENTER) and xbeK_CTRL_I (TAB) as hot 
keys but wanted the pressing of ENTER and TAB to behave normally 
and not activate the hotkey.

aButtons := { xbeK_CTRL_M, {||Ctrl_M_Key()}, ;
              xbeK_CTRL_I, {||Ctrl_I_Key()} }

@ 1,0 DCPUSHBUTTON .. ACTION aButtons[1,2] ACCELKEY aButtons[1,1]
@ 2,0 DCPUSHBUTTON .. ACTION aButtons[2,2] ACCELKEY aButtons[2,1]

bHandler := {|a,b,c,d,e,f,g,h|My_EventHandler(a,b,c,d,e,f,@g,h)}

DCREAD GUI HANDLERBLOCK bHandler

STATIC FUNCTION ;
  My_EventHandler( nEvent, mp1, mp2, oXbp, oDlg, GetList, aButtons )

LOCAL nButton, nKeyState := AppKeyState( xbeK_CTRL )

IF nEvent == xbeP_Keyboard
  nButton := AScan( aButtons, {|a|a[1]==mp1} )
  IF nButton > 0
    IF nKeyState == 1  // Ctrl key down
      Eval( aButtons[nButton,2], nil, nil, oXbp )
      RETURN DCGUI_IGNORE
    ELSE // Ctrl key up
      RETURN DCGUI_NOHOTKEY
    ENDIF
  ENDIF
ENDIF
RETURN DCGUI_NONE
I think that the following:
DCREAD GUI HANDLERBLOCK bHandler

Should be:
DCREAD GUI HANDLERBLOCK bHandler REFERENCE aButtons

If I understand the concept of the REFERENCE and the HANDLER it should be changed, otherwise I don't understand how this works.
Best regards,

Chris.
www.aboservice.be

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

Re: Documentation dcread gui example 2

#2 Post by rdonnay »

Chris -

Yes, I agree. That was a mistake that I left out the REFERENCE aButtons in the documentation.

I will fix that.
The eXpress train is coming - and it has more cars.

Post Reply