Documentation dcread gui example 2
Posted: Wed Mar 29, 2023 12:22 am
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.
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.
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
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.