Hi guys,
when I start to understand class... it was to understand HMG4...
Now, I write my little/personal version about HMG4 core and I find solution for enter on a textbox. I've modified some HMG4 source and this is the code.
The solution (my solution) is to specialize the "keyoard event" for any control/widget.
Anyway, I give my solution with HMG4
source name control.prg
I do some modification
Code: Select all
/*----------------------------------------------------------------------*/
METHOD OnEnter( bOnEnter ) CLASS CONTROL
IF ::lCreated
IF PCOUNT() == 0
RETURN ::bOnEnter
ELSEIF HB_ISBLOCK( bOnEnter ) == .T.
::bOnEnter := bOnEnter
RETURN NIL
ENDIF
ELSE
IF PCOUNT() == 0
RETURN ::bOnEnter
ELSEIF HB_ISBLOCK( bOnEnter ) == .T.
::bOnEnter := bOnEnter
RETURN NIL
ENDIF
ENDIF
RETURN NIL
source name textbox.prg
Added this method
Connect DoKeyBoardEvents (near line 570)
Code: Select all
IF !::lGridCellFlag
* FOR KeyBoardEventProcessing...
::oQTObject:Connect( QEvent_KeyPress , {|e| Self:DoKeyBoardEvents( e )} )
IF ValType( ::lVisible ) != 'U' ; Self:Visible := ::lVisible ; ELSE ; ::oQTObject:show() ; ENDIF
ENDIF
Code of KeyBoardEvents method
Code: Select all
/*----------------------------------------------------------------------*/
METHOD TEXTBOX:DoKeyBoardEvents( e )
LOCAL oKeyEvent := QKeyEventFromPointer( e )
LOCAL nKey := oKeyEvent:key()
LOCAL nModifiers := oKeyEvent:modifiers()
HB_SYMBOL_UNUSED( nModifiers )
IF nKey == Qt_Key_Return .OR. nKey == Qt_Key_Enter
IF HB_ISBLOCK ( ::bOnEnter )
EVAL( ::bOnEnter )
RETURN .T.
ENDIF
ENDIF
RETURN ::oQTObject:Event( oKeyEvent )
Now You can use
Code: Select all
DEFINE TEXTBOX name
ROW ....
COL....
VALUE "sdisdui"
ONENTER {|| OnEnterFunction() }
END TEXTBOX
Best regards to everyone.